Skip to content

Commit 20ad4e5

Browse files
Merge pull request #3893 from Nirmal4G/hotfix/clean-up
Clean-up project files and MSBuild logic
2 parents d0f577f + d52cc99 commit 20ad4e5

File tree

6 files changed

+72
-64
lines changed

6 files changed

+72
-64
lines changed

Microsoft.Toolkit.Diagnostics/Microsoft.Toolkit.Diagnostics.csproj

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,35 @@
1313
</Description>
1414
<PackageTags>Windows;Community;Toolkit;WCT;UWP;Incremental;Loading;Collection;IncrementalLoadingCollection;String;Array;extensions;helpers</PackageTags>
1515
</PropertyGroup>
16+
1617
<Choose>
17-
<When Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
18+
<When Condition="'$(TargetFramework)' == 'netstandard1.4'">
19+
<!-- .NET Standard 1.4 doesn't have the Span<T> type, ValueTuple or the [Pure] attribute -->
1820
<ItemGroup>
19-
20-
<!-- .NET Standard 1.4 doesn't have the Span<T> type, ValueTuple or the [Pure] attribute -->
2121
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
2222
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
2323
<PackageReference Include="System.Memory" Version="4.5.4" />
2424
</ItemGroup>
2525
</When>
26-
<When Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
27-
<ItemGroup>
2826

29-
<!-- .NET Standard 2.0 doesn't have the Span<T> type -->
27+
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
28+
<!-- .NET Standard 2.0 doesn't have the Span<T> type -->
29+
<ItemGroup>
3030
<PackageReference Include="System.Memory" Version="4.5.4" />
3131
</ItemGroup>
3232
</When>
33-
<When Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
33+
34+
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
3435
<PropertyGroup>
3536
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
3637
</PropertyGroup>
38+
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
3739
<ItemGroup>
38-
39-
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
4040
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
4141
</ItemGroup>
4242
</When>
43-
<When Condition=" '$(TargetFramework)' == 'net5.0' ">
43+
44+
<When Condition="'$(TargetFramework)' == 'net5.0'">
4445
<PropertyGroup>
4546
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
4647
</PropertyGroup>

Microsoft.Toolkit.HighPerformance/Microsoft.Toolkit.HighPerformance.csproj

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@
2424
</Description>
2525
<PackageTags>Windows;Community;Toolkit;WCT;UWP;core;standard;unsafe;span;memory;string;array;stream;buffer;extensions;helpers;parallel;performance</PackageTags>
2626
</PropertyGroup>
27+
2728
<Choose>
28-
<When Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
29+
<When Condition="'$(TargetFramework)' == 'netstandard1.4'">
30+
<!--
31+
.NET Standard 1.4 lacks the [Pure] attribute, the Rectangle primitive,
32+
the Span<T> and Memory<T> types, the Vector<T> primitive and related APIs,
33+
ValueTask and ValueTask<T>, the Parallel class and the Unsafe class.
34+
We also need to reference the System.Runtime.CompilerServices.Unsafe package directly,
35+
even though System.Memory references it already, as we need a more recent version than
36+
the one bundled with it. This is so that we can use the Unsafe.Unbox<T> method,
37+
which is used by the Box<T> type in the package.
38+
-->
2939
<ItemGroup>
30-
31-
<!-- .NET Standard 1.4 lacks the [Pure] attribute, the Rectangle primitive,
32-
the Span<T> and Memory<T> types, the Vector<T> primitive and related APIs,
33-
ValueTask and ValueTask<T>, the Parallel class and the Unsafe class.
34-
We also need to reference the System.Runtime.CompilerServices.Unsafe package directly,
35-
even though System.Memory references it already, as we need a more recent version than
36-
the one bundled with it. This is so that we can use the Unsafe.Unbox<T> method,
37-
which is used by the Box<T> type in the package. -->
3840
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
3941
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" />
4042
<PackageReference Include="System.Memory" Version="4.5.4" />
@@ -44,65 +46,70 @@
4446
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
4547
</ItemGroup>
4648
</When>
47-
<When Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
48-
<ItemGroup>
4949

50-
<!-- .NET Standard 2.0 doesn't have the Span<T>, HashCode and ValueTask types -->
50+
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
51+
<!-- .NET Standard 2.0 doesn't have the Span<T>, HashCode and ValueTask types -->
52+
<ItemGroup>
5153
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
5254
<PackageReference Include="System.Memory" Version="4.5.4" />
5355
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
5456
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
5557
</ItemGroup>
5658
</When>
57-
<When Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
58-
<ItemGroup>
5959

60-
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
61-
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
62-
</ItemGroup>
63-
<PropertyGroup>
64-
65-
<!-- NETSTANDARD2_1_OR_GREATER: includes both .NET Standard 2.1 and .NET Core 3.1.
66-
This is needed because .NET Core 3.1 will be a separate package than .NET Standard 2.1. -->
60+
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
61+
<!--
62+
NETSTANDARD2_1_OR_GREATER: includes both .NET Standard 2.1 and .NET Core 3.1.
63+
This is needed because .NET Core 3.1 will be a separate package than .NET Standard 2.1.
6764
68-
<!-- SPAN_RUNTIME_SUPPORT: define a constant to indicate runtimes with runtime support for
69-
the fast Span<T> type, as well as some overloads with Span<T> parameters (eg. Stream.Write).
70-
In particular, these are runtimes which are able to create Span<T> instances from just
71-
a managed reference, which can be used to slice arbitrary objects not technically supported.
72-
This API (MemoryMarshal.CreateSpan) is not part of .NET Standard 2.0, but it is still
73-
available on .NET Core 2.1. So by using this constant, we can make sure to expose those
74-
APIs relying on that method on all target frameworks that are able to support them. -->
75-
<DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT</DefineConstants>
76-
</PropertyGroup>
77-
</When>
78-
<When Condition=" '$(TargetFramework)' == 'net5.0' ">
65+
SPAN_RUNTIME_SUPPORT: define a constant to indicate runtimes with runtime support for
66+
the fast Span<T> type, as well as some overloads with Span<T> parameters (eg. Stream.Write).
67+
In particular, these are runtimes which are able to create Span<T> instances from just
68+
a managed reference, which can be used to slice arbitrary objects not technically supported.
69+
This API (MemoryMarshal.CreateSpan) is not part of .NET Standard 2.0, but it is still
70+
available on .NET Core 2.1. So by using this constant, we can make sure to expose those
71+
APIs relying on that method on all target frameworks that are able to support them.
72+
-->
7973
<PropertyGroup>
8074
<DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT</DefineConstants>
8175
</PropertyGroup>
82-
</When>
83-
<When Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
76+
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
8477
<ItemGroup>
8578
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
8679
</ItemGroup>
80+
</When>
81+
82+
<When Condition="'$(TargetFramework)' == 'net5.0'">
8783
<PropertyGroup>
84+
<DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT</DefineConstants>
85+
</PropertyGroup>
86+
</When>
8887

89-
<!-- NETCORE_RUNTIME: to avoid issues with APIs that assume a specific memory layout, we define a
90-
.NET Core runtime constant to indicate either .NET Core 2.1 or .NET Core 3.1. These are
91-
runtimes with the same overall memory layout for objects (in particular: strings, SZ arrays,
92-
and ND arrays). We can use this constant to make sure that APIs that are exclusively available
93-
for .NET Standard targets do not make any assumtpion of any internals of the runtime being
94-
actually used by the consumers. .NET 5.0 would fall into this category as well, but we don't
95-
need to include that target as it offers APIs that don't require runtime-based workarounds.-->
88+
<When Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
89+
<!--
90+
NETCORE_RUNTIME: to avoid issues with APIs that assume a specific memory layout, we define a
91+
.NET Core runtime constant to indicate either .NET Core 2.1 or .NET Core 3.1. These are
92+
runtimes with the same overall memory layout for objects (in particular: strings, SZ arrays,
93+
and ND arrays). We can use this constant to make sure that APIs that are exclusively available
94+
for .NET Standard targets do not make any assumtpion of any internals of the runtime being
95+
actually used by the consumers. .NET 5.0 would fall into this category as well, but we don't
96+
need to include that target as it offers APIs that don't require runtime-based workarounds.
97+
-->
98+
<PropertyGroup>
9699
<DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT;NETCORE_RUNTIME</DefineConstants>
97100
</PropertyGroup>
98-
</When>
99-
<When Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
100101
<ItemGroup>
101102
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
102103
</ItemGroup>
104+
</When>
105+
106+
<When Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
103107
<PropertyGroup>
104108
<DefineConstants>SPAN_RUNTIME_SUPPORT;NETCORE_RUNTIME</DefineConstants>
105109
</PropertyGroup>
110+
<ItemGroup>
111+
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
112+
</ItemGroup>
106113
</When>
107114
</Choose>
108115

Microsoft.Toolkit.Mvvm/Microsoft.Toolkit.Mvvm.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
</PropertyGroup>
2222

2323
<!-- .NET Standard 2.0 doesn't have the Span<T> and IAsyncEnumerable<T> types -->
24-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
24+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
2525
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
2626
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
2727
<PackageReference Include="System.Memory" Version="4.5.4" />
2828
</ItemGroup>
2929

3030
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
31-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
31+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
3232
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
3333
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
3434
</ItemGroup>

Microsoft.Toolkit/Microsoft.Toolkit.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
<PackageTags>Windows;Community;Toolkit;WCT;UWP;Incremental;Loading;Collection;IncrementalLoadingCollection;String;Array;extensions;helpers</PackageTags>
1515
</PropertyGroup>
1616

17-
<!-- .NET Standard 1.4 doesn't have the [Pure] attribute -->
18-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
19-
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
20-
</ItemGroup>
21-
2217
<!-- .NET Standard 2.1 and .NET 5 already have [NotNullIfNotNull] and [NotNullWhen] -->
23-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'net5.0' ">
18+
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'net5.0'">
2419
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
2520
</PropertyGroup>
2621

22+
<!-- .NET Standard 1.4 doesn't have the [Pure] attribute -->
23+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.4'">
24+
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
25+
</ItemGroup>
26+
2727
</Project>

UnitTests/UnitTests.HighPerformance.NetCore/UnitTests.HighPerformance.NetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<!-- .NET Core 2.1 doesn't have the Unsafe type -->
11-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
11+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
1212
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
1313
</ItemGroup>
1414

UnitTests/UnitTests.NetCore/UnitTests.NetCore.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
<ItemGroup>
1010
<PackageReference Include="FluentAssertions" Version="5.10.3" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
1212
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
1313
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
1414
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
1515
</ItemGroup>
1616

1717
<!-- Workaround for the .NET Core 2.1 binary not resolving the Unsafe assembly properly -->
18-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
18+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
1919
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
2020
</ItemGroup>
2121

0 commit comments

Comments
 (0)