| File: Json\NullableExtensions.cs | Web Access |
| Project: src\sdk\src\RazorSdk\Tool\Microsoft.NET.Sdk.Razor.Tool.csproj (rzc) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime; using System.Runtime.CompilerServices; namespace Microsoft.NET.Sdk.Razor.Tool.Json; internal static class NullableExtensions { [DebuggerStepThrough] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static T AssumeNotNull<T>( [NotNull] this T? value, string? message = null, [CallerArgumentExpression(nameof(value))] string? valueExpression = null, [CallerFilePath] string? path = null, [CallerLineNumber] int line = 0) where T : class { Assumed.NotNull(value, message, valueExpression, path, line); return value; } [DebuggerStepThrough] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static T AssumeNotNull<T>( [NotNull] this T? value, [InterpolatedStringHandlerArgument(nameof(value))] Assumed.ThrowIfNullInterpolatedStringHandler<T> message, [CallerFilePath] string? path = null, [CallerLineNumber] int line = 0) where T : class { Assumed.NotNull(value, message, path, line); return value; } [DebuggerStepThrough] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static T AssumeNotNull<T>( [NotNull] this T? value, string? message = null, [CallerArgumentExpression(nameof(value))] string? valueExpression = null, [CallerFilePath] string? path = null, [CallerLineNumber] int line = 0) where T : struct { Assumed.NotNull(value, message, valueExpression, path, line); return value.GetValueOrDefault(); } [DebuggerStepThrough] [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] public static T AssumeNotNull<T>( [NotNull] this T? value, [InterpolatedStringHandlerArgument(nameof(value))] Assumed.ThrowIfNullInterpolatedStringHandler<T> message, [CallerFilePath] string? path = null, [CallerLineNumber] int line = 0) where T : struct { Assumed.NotNull(value, message, path, line); return value.GetValueOrDefault(); } }