-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable nullables on TRX logger (#3754)
- Loading branch information
1 parent
cb927f7
commit 80b893e
Showing
50 changed files
with
710 additions
and
595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/IDataAttachment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
src/Microsoft.TestPlatform.Extensions.TrxLogger/Interfaces/ITestElement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...Platform.Extensions.TrxLogger/Microsoft - Backup.TestPlatform.Extensions.TrxLogger.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TestPlatformRoot Condition="$(TestPlatformRoot) == ''">..\..\</TestPlatformRoot> | ||
</PropertyGroup> | ||
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" /> | ||
<PropertyGroup> | ||
<AssemblyName>Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger</AssemblyName> | ||
<TargetFrameworks>netstandard2.0;net451</TargetFrameworks> | ||
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">net6.0</TargetFrameworks> | ||
<IsTestProject>false</IsTestProject> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="Resources\TrxResource.resx" /> | ||
</ItemGroup> | ||
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' "> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Runtime" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.TestHostProvider\Properties\TestExtensionTypesAttribute.cs" Link="Properties\TestExtensionTypesAttribute.cs" /> | ||
<Compile Include="..\..\shared\NullableAttributes.cs" Link="NullableAttributes.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" /> | ||
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' "> | ||
<PackageReference Include="System.Security.Principal.Windows" Version="4.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' "> | ||
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Update="NullableHelpers.cs"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>NullableHelpers.tt</DependentUpon> | ||
</Compile> | ||
<Compile Update="Resources\TrxResource.Designer.cs"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>TrxResource.resx</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Update="Resources\TrxResource.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>TrxResource.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<RootNamespace>Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger</RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<!-- API that is common to all frameworks that we build for. --> | ||
<AdditionalFiles Include="PublicAPI/PublicAPI.Shipped.txt" /> | ||
<AdditionalFiles Include="PublicAPI/PublicAPI.Unshipped.txt" /> | ||
<!-- Framework specific API --> | ||
<AdditionalFiles Include="PublicAPI/$(TargetFramework)/PublicAPI.Shipped.txt" /> | ||
<AdditionalFiles Include="PublicAPI/$(TargetFramework)/PublicAPI.Unshipped.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="NullableHelpers.tt"> | ||
<LastGenOutput>NullableHelpers.cs</LastGenOutput> | ||
<Generator>TextTemplatingFileGenerator</Generator> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> | ||
</ItemGroup> | ||
<Import Project="$(TestPlatformRoot)scripts\build\TestPlatform.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Microsoft.TestPlatform.Extensions.TrxLogger/NullableHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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.VisualStudio.TestPlatform.Extensions.TrxLogger; | ||
|
||
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="TPDebug.Assert(bool)"/> | ||
[Conditional("DEBUG")] | ||
public static void Assert([DoesNotReturnIf(false)] bool b) | ||
=> TPDebug.Assert(b); | ||
|
||
/// <inheritdoc cref="TPDebug.Assert(bool, string)"/> | ||
[Conditional("DEBUG")] | ||
public static void Assert([DoesNotReturnIf(false)] bool b, string message) | ||
=> TPDebug.Assert(b, message); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/Microsoft.TestPlatform.Extensions.TrxLogger/NullableHelpers.tt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<#@ template debug="true" hostspecific="true" language="C#" #> | ||
<#@ output extension=".cs" #> | ||
<#@ assembly name="System.Core" #> | ||
// 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 <#= System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("NamespaceHint") #>; | ||
|
||
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="TPDebug.Assert(bool)"/> | ||
[Conditional("DEBUG")] | ||
public static void Assert([DoesNotReturnIf(false)] bool b) | ||
=> TPDebug.Assert(b); | ||
|
||
/// <inheritdoc cref="TPDebug.Assert(bool, string)"/> | ||
[Conditional("DEBUG")] | ||
public static void Assert([DoesNotReturnIf(false)] bool b, string message) | ||
=> TPDebug.Assert(b, message); | ||
} |
Oops, something went wrong.