1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2025-04-13 20:15:45 +02:00

Merge pull request from Nirmal4G/hotfix/clean-up

Clean-up project files and MSBuild logic
This commit is contained in:
Michael Hawker MSFT (XAML Llama) 2021-06-15 14:16:22 -07:00 committed by GitHub
commit 20ad4e505b
6 changed files with 74 additions and 66 deletions
Microsoft.Toolkit.Diagnostics
Microsoft.Toolkit.HighPerformance
Microsoft.Toolkit.Mvvm
Microsoft.Toolkit
UnitTests
UnitTests.HighPerformance.NetCore
UnitTests.NetCore

View File

@ -13,34 +13,35 @@
</Description>
<PackageTags>Windows;Community;Toolkit;WCT;UWP;Incremental;Loading;Collection;IncrementalLoadingCollection;String;Array;extensions;helpers</PackageTags>
</PropertyGroup>
<Choose>
<When Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
<ItemGroup>
<!-- .NET Standard 1.4 doesn't have the Span<T> type, ValueTuple or the [Pure] attribute -->
<Choose>
<When Condition="'$(TargetFramework)' == 'netstandard1.4'">
<!-- .NET Standard 1.4 doesn't have the Span<T> type, ValueTuple or the [Pure] attribute -->
<ItemGroup>
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup>
<!-- .NET Standard 2.0 doesn't have the Span<T> type -->
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
<!-- .NET Standard 2.0 doesn't have the Span<T> type -->
<ItemGroup>
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PropertyGroup>
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
</PropertyGroup>
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
<ItemGroup>
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net5.0' ">
<When Condition="'$(TargetFramework)' == 'net5.0'">
<PropertyGroup>
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
</PropertyGroup>

View File

@ -24,17 +24,19 @@
</Description>
<PackageTags>Windows;Community;Toolkit;WCT;UWP;core;standard;unsafe;span;memory;string;array;stream;buffer;extensions;helpers;parallel;performance</PackageTags>
</PropertyGroup>
<Choose>
<When Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
<ItemGroup>
<!-- .NET Standard 1.4 lacks the [Pure] attribute, the Rectangle primitive,
the Span<T> and Memory<T> types, the Vector<T> primitive and related APIs,
ValueTask and ValueTask<T>, the Parallel class and the Unsafe class.
We also need to reference the System.Runtime.CompilerServices.Unsafe package directly,
even though System.Memory references it already, as we need a more recent version than
the one bundled with it. This is so that we can use the Unsafe.Unbox<T> method,
which is used by the Box<T> type in the package. -->
<Choose>
<When Condition="'$(TargetFramework)' == 'netstandard1.4'">
<!--
.NET Standard 1.4 lacks the [Pure] attribute, the Rectangle primitive,
the Span<T> and Memory<T> types, the Vector<T> primitive and related APIs,
ValueTask and ValueTask<T>, the Parallel class and the Unsafe class.
We also need to reference the System.Runtime.CompilerServices.Unsafe package directly,
even though System.Memory references it already, as we need a more recent version than
the one bundled with it. This is so that we can use the Unsafe.Unbox<T> method,
which is used by the Box<T> type in the package.
-->
<ItemGroup>
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
@ -44,65 +46,70 @@
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup>
<!-- .NET Standard 2.0 doesn't have the Span<T>, HashCode and ValueTask types -->
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
<!-- .NET Standard 2.0 doesn't have the Span<T>, HashCode and ValueTask types -->
<ItemGroup>
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<ItemGroup>
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
<!--
NETSTANDARD2_1_OR_GREATER: includes both .NET Standard 2.1 and .NET Core 3.1.
This is needed because .NET Core 3.1 will be a separate package than .NET Standard 2.1.
SPAN_RUNTIME_SUPPORT: define a constant to indicate runtimes with runtime support for
the fast Span<T> type, as well as some overloads with Span<T> parameters (eg. Stream.Write).
In particular, these are runtimes which are able to create Span<T> instances from just
a managed reference, which can be used to slice arbitrary objects not technically supported.
This API (MemoryMarshal.CreateSpan) is not part of .NET Standard 2.0, but it is still
available on .NET Core 2.1. So by using this constant, we can make sure to expose those
APIs relying on that method on all target frameworks that are able to support them.
-->
<PropertyGroup>
<!-- NETSTANDARD2_1_OR_GREATER: includes both .NET Standard 2.1 and .NET Core 3.1.
This is needed because .NET Core 3.1 will be a separate package than .NET Standard 2.1. -->
<!-- SPAN_RUNTIME_SUPPORT: define a constant to indicate runtimes with runtime support for
the fast Span<T> type, as well as some overloads with Span<T> parameters (eg. Stream.Write).
In particular, these are runtimes which are able to create Span<T> instances from just
a managed reference, which can be used to slice arbitrary objects not technically supported.
This API (MemoryMarshal.CreateSpan) is not part of .NET Standard 2.0, but it is still
available on .NET Core 2.1. So by using this constant, we can make sure to expose those
APIs relying on that method on all target frameworks that are able to support them. -->
<DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT</DefineConstants>
</PropertyGroup>
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'net5.0' ">
<When Condition="'$(TargetFramework)' == 'net5.0'">
<PropertyGroup>
<DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT</DefineConstants>
</PropertyGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
<PropertyGroup>
<!-- NETCORE_RUNTIME: to avoid issues with APIs that assume a specific memory layout, we define a
.NET Core runtime constant to indicate either .NET Core 2.1 or .NET Core 3.1. These are
runtimes with the same overall memory layout for objects (in particular: strings, SZ arrays,
and ND arrays). We can use this constant to make sure that APIs that are exclusively available
for .NET Standard targets do not make any assumtpion of any internals of the runtime being
actually used by the consumers. .NET 5.0 would fall into this category as well, but we don't
need to include that target as it offers APIs that don't require runtime-based workarounds.-->
<When Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<!--
NETCORE_RUNTIME: to avoid issues with APIs that assume a specific memory layout, we define a
.NET Core runtime constant to indicate either .NET Core 2.1 or .NET Core 3.1. These are
runtimes with the same overall memory layout for objects (in particular: strings, SZ arrays,
and ND arrays). We can use this constant to make sure that APIs that are exclusively available
for .NET Standard targets do not make any assumtpion of any internals of the runtime being
actually used by the consumers. .NET 5.0 would fall into this category as well, but we don't
need to include that target as it offers APIs that don't require runtime-based workarounds.
-->
<PropertyGroup>
<DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT;NETCORE_RUNTIME</DefineConstants>
</PropertyGroup>
</When>
<When Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
<When Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PropertyGroup>
<DefineConstants>SPAN_RUNTIME_SUPPORT;NETCORE_RUNTIME</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
</Choose>

View File

@ -21,14 +21,14 @@
</PropertyGroup>
<!-- .NET Standard 2.0 doesn't have the Span<T> and IAsyncEnumerable<T> types -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
<!-- .NET Standard 2.1 doesn't have the Unsafe type -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>

View File

@ -14,14 +14,14 @@
<PackageTags>Windows;Community;Toolkit;WCT;UWP;Incremental;Loading;Collection;IncrementalLoadingCollection;String;Array;extensions;helpers</PackageTags>
</PropertyGroup>
<!-- .NET Standard 1.4 doesn't have the [Pure] attribute -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
</ItemGroup>
<!-- .NET Standard 2.1 and .NET 5 already have [NotNullIfNotNull] and [NotNullWhen] -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'net5.0' ">
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1' OR '$(TargetFramework)' == 'net5.0'">
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
</PropertyGroup>
<!-- .NET Standard 1.4 doesn't have the [Pure] attribute -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.4'">
<PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" />
</ItemGroup>
</Project>

View File

@ -8,7 +8,7 @@
</PropertyGroup>
<!-- .NET Core 2.1 doesn't have the Unsafe type -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>

View File

@ -8,14 +8,14 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
</ItemGroup>
<!-- Workaround for the .NET Core 2.1 binary not resolving the Unsafe assembly properly -->
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>