Last active
June 22, 2021 16:31
-
-
Save martincostello/55cba81cc1a58e0f895b89b714f9b3c5 to your computer and use it in GitHub Desktop.
.NET global usings for code and tests
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
Microsoft Visual Studio Solution File, Format Version 12.00 | |
# Visual Studio Version 17 | |
VisualStudioVersion = 17.0.31410.414 | |
MinimumVisualStudioVersion = 10.0.40219.1 | |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console", "Console\Console.csproj", "{14C9E029-8F1A-405A-9EA6-C19F9155EE93}" | |
EndProject | |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console.Tests", "Console.Tests\Console.Tests.csproj", "{461065E4-6BF5-4323-ADF3-1AD8B6699910}" | |
EndProject | |
Global | |
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
Debug|Any CPU = Debug|Any CPU | |
Release|Any CPU = Release|Any CPU | |
EndGlobalSection | |
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |
{14C9E029-8F1A-405A-9EA6-C19F9155EE93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
{14C9E029-8F1A-405A-9EA6-C19F9155EE93}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
{14C9E029-8F1A-405A-9EA6-C19F9155EE93}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
{14C9E029-8F1A-405A-9EA6-C19F9155EE93}.Release|Any CPU.Build.0 = Release|Any CPU | |
{461065E4-6BF5-4323-ADF3-1AD8B6699910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |
{461065E4-6BF5-4323-ADF3-1AD8B6699910}.Debug|Any CPU.Build.0 = Debug|Any CPU | |
{461065E4-6BF5-4323-ADF3-1AD8B6699910}.Release|Any CPU.ActiveCfg = Release|Any CPU | |
{461065E4-6BF5-4323-ADF3-1AD8B6699910}.Release|Any CPU.Build.0 = Release|Any CPU | |
EndGlobalSection | |
GlobalSection(SolutionProperties) = preSolution | |
HideSolutionNode = FALSE | |
EndGlobalSection | |
GlobalSection(ExtensibilityGlobals) = postSolution | |
SolutionGuid = {CD72F94B-2B4A-471C-9C61-06563D05B477} | |
EndGlobalSection | |
EndGlobal |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>net6.0</TargetFramework> | |
<IsPackable>false</IsPackable> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" /> | |
<PackageReference Include="xunit" Version="2.4.1" /> | |
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" /> | |
</ItemGroup> | |
</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
namespace Console.Tests | |
{ | |
public class UnitTest1 | |
{ | |
[Fact] | |
public void Test1() | |
{ | |
Assert.True(DateTime.UtcNow > DateTime.MinValue); | |
} | |
} | |
} |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net6.0</TargetFramework> | |
</PropertyGroup> | |
</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
Console.WriteLine("Hello World!"); |
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
<Project> | |
<PropertyGroup> | |
<LangVersion>preview</LangVersion> | |
<NoWarn>$(NoWarn);CS0105</NoWarn> | |
</PropertyGroup> | |
<ItemGroup> | |
<!-- Automatically add the GlobalUsings.cs file to all projects --> | |
<Compile Include="$(MSBuildThisFileDirectory)\GlobalUsings.cs" /> | |
</ItemGroup> | |
</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
<Project> | |
<!-- Automatically define TEST_PROJECT in all test projects --> | |
<PropertyGroup Condition=" '$(IsTestProject)' == 'true' "> | |
<DefineConstants>$(DefineConstants);TEST_PROJECT</DefineConstants> | |
</PropertyGroup> | |
</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
global using System; | |
// Add test-specific usings to all test projects | |
#if TEST_PROJECT | |
global using Xunit; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment