/
githubmirror
/
PowerShell
Обзор
Документация
Войти
/
githubmirror
/
PowerShell
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/System.Management.Automation/engine/ComInterop/Helpers.cs
53 строки
1 KB
xtqqczze
Use `CallerArgumentExpression` on `Requires.NotNull` (#19200)
23 фев 2023, 21:21
Не верифицирован
23 фев 2023, 21:21
6055a82
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. #nullable enable using System; using System.Linq.Expressions; using System.Runtime.CompilerServices; namespace System.Management.Automation.ComInterop { // Miscellaneous helpers that don't belong anywhere else internal static class Helpers { internal static Expression Convert(Expression expression, Type type) { if (expression.Type == type) { return expression; } if (expression.Type == typeof(void)) { return Expression.Block(expression, Expression.Default(type)); } if (type == typeof(void)) { return Expression.Block(expression, Expression.Empty()); } return Expression.Convert(expression, type); } } internal static class Requires { [System.Diagnostics.Conditional("DEBUG")] internal static void NotNull(object value, [CallerArgumentExpression("value")] string? paramName = null) { ArgumentNullException.ThrowIfNull(value, paramName); } [System.Diagnostics.Conditional("DEBUG")] internal static void Condition(bool precondition, string paramName) { if (!precondition) { throw new ArgumentException(paramName); } } } }