|
24 | 24 | </Description> |
25 | 25 | <PackageTags>Windows;Community;Toolkit;WCT;UWP;core;standard;unsafe;span;memory;string;array;stream;buffer;extensions;helpers;parallel;performance</PackageTags> |
26 | 26 | </PropertyGroup> |
| 27 | + |
27 | 28 | <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 | + --> |
29 | 39 | <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. --> |
38 | 40 | <PackageReference Include="System.Diagnostics.Contracts" Version="4.3.0" /> |
39 | 41 | <PackageReference Include="System.Drawing.Primitives" Version="4.3.0" /> |
40 | 42 | <PackageReference Include="System.Memory" Version="4.5.4" /> |
|
44 | 46 | <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" /> |
45 | 47 | </ItemGroup> |
46 | 48 | </When> |
47 | | - <When Condition=" '$(TargetFramework)' == 'netstandard2.0' "> |
48 | | - <ItemGroup> |
49 | 49 |
|
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> |
51 | 53 | <PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" /> |
52 | 54 | <PackageReference Include="System.Memory" Version="4.5.4" /> |
53 | 55 | <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" /> |
54 | 56 | <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" /> |
55 | 57 | </ItemGroup> |
56 | 58 | </When> |
57 | | - <When Condition=" '$(TargetFramework)' == 'netstandard2.1' "> |
58 | | - <ItemGroup> |
59 | 59 |
|
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. |
67 | 64 |
|
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 | + --> |
79 | 73 | <PropertyGroup> |
80 | 74 | <DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT</DefineConstants> |
81 | 75 | </PropertyGroup> |
82 | | - </When> |
83 | | - <When Condition=" '$(TargetFramework)' == 'netcoreapp3.1' "> |
| 76 | + <!-- .NET Standard 2.1 doesn't have the Unsafe type --> |
84 | 77 | <ItemGroup> |
85 | 78 | <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" /> |
86 | 79 | </ItemGroup> |
| 80 | + </When> |
| 81 | + |
| 82 | + <When Condition="'$(TargetFramework)' == 'net5.0'"> |
87 | 83 | <PropertyGroup> |
| 84 | + <DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT</DefineConstants> |
| 85 | + </PropertyGroup> |
| 86 | + </When> |
88 | 87 |
|
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> |
96 | 99 | <DefineConstants>NETSTANDARD2_1_OR_GREATER;SPAN_RUNTIME_SUPPORT;NETCORE_RUNTIME</DefineConstants> |
97 | 100 | </PropertyGroup> |
98 | | - </When> |
99 | | - <When Condition=" '$(TargetFramework)' == 'netcoreapp2.1' "> |
100 | 101 | <ItemGroup> |
101 | 102 | <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" /> |
102 | 103 | </ItemGroup> |
| 104 | + </When> |
| 105 | + |
| 106 | + <When Condition="'$(TargetFramework)' == 'netcoreapp2.1'"> |
103 | 107 | <PropertyGroup> |
104 | 108 | <DefineConstants>SPAN_RUNTIME_SUPPORT;NETCORE_RUNTIME</DefineConstants> |
105 | 109 | </PropertyGroup> |
| 110 | + <ItemGroup> |
| 111 | + <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" /> |
| 112 | + </ItemGroup> |
106 | 113 | </When> |
107 | 114 | </Choose> |
108 | 115 |
|
|
0 commit comments