Skip to content

Commit 765901a

Browse files
committed
Centralize NETSTANDARD2_1_OR_GREATER define in .targets
1 parent 9d9de23 commit 765901a

File tree

4 files changed

+9
-29
lines changed

4 files changed

+9
-29
lines changed

src/CommunityToolkit.Common/CommunityToolkit.Common.csproj

-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
<PackageTags>Incremental;Loading;Collection;IncrementalLoadingCollection;String;Array;Extensions;Helpers</PackageTags>
1515
</PropertyGroup>
1616

17-
<!-- .NET Standard 2.1 and .NET 6 already have [NotNullIfNotNull] and [NotNullWhen] -->
18-
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
19-
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
20-
</PropertyGroup>
21-
2217
<!-- Necessary polyfills -->
2318
<PropertyGroup>
2419
<PolySharpIncludeGeneratedTypes>

src/CommunityToolkit.Diagnostics/CommunityToolkit.Diagnostics.csproj

+3-14
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,20 @@
1515
</PropertyGroup>
1616

1717
<Choose>
18-
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
1918

20-
<!-- .NET Standard 2.0 doesn't have the Span<T> type -->
19+
<!-- .NET Standard 2.0 doesn't have the Span<T> type -->
20+
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
2121
<ItemGroup>
2222
<PackageReference Include="System.Memory" Version="4.5.5" />
2323
</ItemGroup>
2424
</When>
2525

26+
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
2627
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
27-
<PropertyGroup>
28-
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
29-
</PropertyGroup>
30-
31-
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
3228
<ItemGroup>
3329
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
3430
</ItemGroup>
3531
</When>
36-
37-
<!-- For the .NET 6 target, simply define NETSTANDARD2_1_OR_GREATER too -->
38-
<When Condition="'$(TargetFramework)' == 'net6.0'">
39-
<PropertyGroup>
40-
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
41-
</PropertyGroup>
42-
</When>
4332
</Choose>
4433

4534
<!-- Necessary polyfills -->

src/CommunityToolkit.HighPerformance/CommunityToolkit.HighPerformance.csproj

+1-10
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,12 @@
4242
</ItemGroup>
4343
</When>
4444

45+
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
4546
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
46-
47-
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
4847
<ItemGroup>
4948
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
5049
</ItemGroup>
5150
</When>
52-
53-
<When Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
54-
55-
<!-- NETSTANDARD2_1_OR_GREATER: includes both .NET Standard 2.1 and .NET 6 and above -->
56-
<PropertyGroup>
57-
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
58-
</PropertyGroup>
59-
</When>
6051
</Choose>
6152

6253
<!-- Necessary polyfills -->

src/Directory.Build.targets

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
<Project>
33
<Import Project="..\Directory.Build.targets" />
44

5+
<!-- Define NETSTANDARD2_1_OR_GREATER for .NET Standard 2.1 targets and above -->
6+
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
7+
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
8+
</PropertyGroup>
9+
510
<!-- Configure trimming for projects on .NET 6 and above -->
611
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
712
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>

0 commit comments

Comments
 (0)