File: NullableHelpers.cs
Web Access
Project: src\src\vstest\src\Microsoft.TestPlatform.Build\Microsoft.TestPlatform.Build.csproj (Microsoft.TestPlatform.Build)
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// <auto-generated>
// This code is auto-generated. Changes to this file will be lost!
// This T4 file is copied in various projects because inclusion as link or through shared project
// doesn't allow to generate the C# file locally. If some modification is required, please update
// all instances.
// </auto-generated>

#nullable enable

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.TestPlatform.Build;

internal static class StringUtils
{
    /// <inheritdoc cref="string.IsNullOrEmpty(string)"/>
    [SuppressMessage("ApiDesign", "RS0030:Do not used banned APIs", Justification = "Replacement API to allow nullable hints for compiler")]
    public static bool IsNullOrEmpty([NotNullWhen(returnValue: false)] this string? value)
        => string.IsNullOrEmpty(value);

    /// <inheritdoc cref="string.IsNullOrWhiteSpace(string)"/>
    [SuppressMessage("ApiDesign", "RS0030:Do not used banned APIs", Justification = "Replacement API to allow nullable hints for compiler")]
    public static bool IsNullOrWhiteSpace([NotNullWhen(returnValue: false)] this string? value)
        => string.IsNullOrWhiteSpace(value);
}

[SuppressMessage("ApiDesign", "RS0030:Do not used banned APIs", Justification = "Replacement API to allow nullable hints for compiler")]
internal static class TPDebug
{
    /// <inheritdoc cref="Debug.Assert(bool)"/>
    [Conditional("DEBUG")]
    public static void Assert([DoesNotReturnIf(false)] bool b)
        => Debug.Assert(b);

    /// <inheritdoc cref="Debug.Assert(bool, string)"/>
    [Conditional("DEBUG")]
    public static void Assert([DoesNotReturnIf(false)] bool b, string message)
        => Debug.Assert(b, message);
}