main/Smdn.MSBuild.DefineConstants.NETSdkApi-1.1.0
Created
March 15, 2022 12:09
-
-
Save smdn/427abbc71345434e67b0430e05c0c550 to your computer and use it in GitHub Desktop.
Smdn.MSBuild.DefineConstants.NETSdkApi 1.1.0 Release Notes
- 2022-03-15 update package version
- 2022-03-15 modify package metadata
- 2022-03-15 add definitions
- 2022-03-15 use C# style generic type name
- 2022-03-15 add README.md to nupkg with the list of symbols defined by the package as a content of it
- 2022-03-15 supress recursive package reference
- 2022-03-15 add comment
- 2022-03-15 add reference
- 2022-03-15 split targets
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
diff --git a/src/Smdn.MSBuild.DefineConstants.NETSdkApi/Directory.Build.targets b/src/Smdn.MSBuild.DefineConstants.NETSdkApi/Directory.Build.targets | |
new file mode 100644 | |
index 00000000..a7ac7a8b | |
--- /dev/null | |
+++ b/src/Smdn.MSBuild.DefineConstants.NETSdkApi/Directory.Build.targets | |
@@ -0,0 +1,109 @@ | |
+<!-- | |
+SPDX-FileCopyrightText: 2022 smdn <smdn@smdn.jp> | |
+SPDX-License-Identifier: MIT | |
+--> | |
+<Project> | |
+ <Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets" /> | |
+ <Import Project="build\$(AssemblyName).targets" /> | |
+ | |
+ <PropertyGroup> | |
+ <NupkgReadmeFileName>README.md</NupkgReadmeFileName> | |
+ <NupkgReadmeFileOutputPath>$(OutputPath)$(NupkgReadmeFileName)</NupkgReadmeFileOutputPath> | |
+ </PropertyGroup> | |
+ | |
+ <ItemGroup> | |
+ <None Include="$(NupkgReadmeFileOutputPath)" Pack="true" PackagePath="$(NupkgReadmeFileName)" /> | |
+ </ItemGroup> | |
+ | |
+ <!-- overrides the target GenerateNupkgReadmeFile from Smdn.MSBuild.ProjectAssets.Library --> | |
+ <Target | |
+ Name="GenerateNupkgReadmeFile" | |
+ BeforeTargets="GenerateNuspec" | |
+ DependsOnTargets="AddAllCompatibleFrameworkVersionConstants" | |
+ > | |
+ <CallTarget Targets="ListNETSdkAvailableApiName"> | |
+ <Output TaskParameter="TargetOutputs" ItemName="_NETSdkAvailableApiSymbol" /> | |
+ </CallTarget> | |
+ | |
+ <SortNETSdkAvailableApiSymbol Symbols="@(_NETSdkAvailableApiSymbol)"> | |
+ <Output TaskParameter="SortedSymbols" ItemName="_SortedNETSdkAvailableApiSymbol" /> | |
+ </SortNETSdkAvailableApiSymbol> | |
+ | |
+ <ItemGroup> | |
+ <_NupkgReadmeLines Include="# $(AssemblyName)" /> | |
+ <_NupkgReadmeLines Include="$(Description)" /> | |
+ <_NupkgReadmeLines Include="## List of symbols to be defined by this package" /> | |
+ <_NupkgReadmeLines Include="- `%(_SortedNETSdkAvailableApiSymbol.Identity)`" /> | |
+ </ItemGroup> | |
+ | |
+ <WriteLinesToFile | |
+ File="$(NupkgReadmeFileOutputPath)" | |
+ Lines="@(_NupkgReadmeLines)" | |
+ Overwrite="true" | |
+ /> | |
+ </Target> | |
+ | |
+ <UsingTask | |
+ TaskName="SortNETSdkAvailableApiSymbol" | |
+ TaskFactory="RoslynCodeTaskFactory" | |
+ AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" | |
+ > | |
+ <ParameterGroup> | |
+ <Symbols ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" /> | |
+ <SortedSymbols ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" /> | |
+ </ParameterGroup> | |
+ <Task> | |
+ <Using Namespace="System" /> | |
+ <Using Namespace="System.Linq" /> | |
+ <Code Type="Fragment" Language="cs"><![CDATA[ | |
+ SortedSymbols = Symbols.OrderBy(static item => item.ItemSpec).ToArray(); | |
+ ]]></Code> | |
+ </Task> | |
+ </UsingTask> | |
+ | |
+ <Target Name="AddAllCompatibleFrameworkVersionConstants"> | |
+ <!-- ref: list of preprocessor symbols for .NET target frameworks: https://docs.microsoft.com/ja-jp/dotnet/standard/frameworks --> | |
+ <ItemGroup> | |
+ <_CompatibleFrameworkVersionConstant Include="NET" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET6_0_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET5_0_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETCOREAPP3_1_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETCOREAPP3_0_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETCOREAPP2_2_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETCOREAPP2_1_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETCOREAPP2_0_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETCOREAPP1_1_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETCOREAPP1_0_OR_GREATER" /> | |
+ | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD2_1_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD2_0_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD1_6_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD1_5_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD1_4_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD1_3_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD1_2_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD1_1_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NETSTANDARD1_0_OR_GREATER" /> | |
+ | |
+ <_CompatibleFrameworkVersionConstant Include="NETFRAMEWORK" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET48_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET472_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET471_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET47_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET462_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET461_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET46_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET452_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET451_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET45_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET40_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET35_OR_GREATER" /> | |
+ <_CompatibleFrameworkVersionConstant Include="NET20_OR_GREATER" /> | |
+ </ItemGroup> | |
+ | |
+ <PropertyGroup> | |
+ <DefineConstants>$(DefineConstants);@(_CompatibleFrameworkVersionConstant, ';')</DefineConstants> | |
+ </PropertyGroup> | |
+ </Target> | |
+</Project> | |
diff --git a/src/Smdn.MSBuild.DefineConstants.NETSdkApi/Smdn.MSBuild.DefineConstants.NETSdkApi.csproj b/src/Smdn.MSBuild.DefineConstants.NETSdkApi/Smdn.MSBuild.DefineConstants.NETSdkApi.csproj | |
index d05217aa..c12c8dfe 100644 | |
--- a/src/Smdn.MSBuild.DefineConstants.NETSdkApi/Smdn.MSBuild.DefineConstants.NETSdkApi.csproj | |
+++ b/src/Smdn.MSBuild.DefineConstants.NETSdkApi/Smdn.MSBuild.DefineConstants.NETSdkApi.csproj | |
@@ -5,7 +5,7 @@ SPDX-License-Identifier: MIT | |
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFrameworks>netstandard1.6</TargetFrameworks> | |
- <VersionPrefix>1.0.0</VersionPrefix> | |
+ <VersionPrefix>1.1.0</VersionPrefix> | |
<VersionSuffix></VersionSuffix> | |
<NoBuild>true</NoBuild> | |
<IncludeBuildOutput>false</IncludeBuildOutput> | |
@@ -17,18 +17,25 @@ SPDX-License-Identifier: MIT | |
<EnablePackageValidation>false</EnablePackageValidation> | |
<APIListEnableGenerating>false</APIListEnableGenerating> | |
+ | |
+ <!-- suppress generating README.md by Smdn.MSBuild.ProjectAssets.Library --> | |
<GeneratePackageReadmeFile>false</GeneratePackageReadmeFile> | |
<_SmdnProjectAssets_ImportFromLocal>true</_SmdnProjectAssets_ImportFromLocal> | |
</PropertyGroup> | |
+ <!-- supress recursive package reference --> | |
+ <ItemGroup> | |
+ <PackageReference Remove="$(AssemblyName)" /> | |
+ </ItemGroup> | |
+ | |
<PropertyGroup Label="assembly attributes"> | |
- <Description>A package to add DefineConstants corresponding to .NET SDK's API catalog.</Description> | |
+ <Description>A package of .targets files to add DefineConstants corresponding to .NET SDK's API catalog.</Description> | |
<CopyrightYear>2022</CopyrightYear> | |
</PropertyGroup> | |
<PropertyGroup Label="package properties"> | |
- <PackageTags>MSBuild;DefineConstants;build-assets</PackageTags> | |
+ <PackageTags>MSBuild;DefineConstants;targets;build-assets</PackageTags> | |
</PropertyGroup> | |
<ItemGroup> | |
diff --git a/src/Smdn.MSBuild.DefineConstants.NETSdkApi/build/Smdn.MSBuild.DefineConstants.NETSdkApi.targets b/src/Smdn.MSBuild.DefineConstants.NETSdkApi/build/Smdn.MSBuild.DefineConstants.NETSdkApi.targets | |
index 9c74efc2..95e1bfbb 100644 | |
--- a/src/Smdn.MSBuild.DefineConstants.NETSdkApi/build/Smdn.MSBuild.DefineConstants.NETSdkApi.targets | |
+++ b/src/Smdn.MSBuild.DefineConstants.NETSdkApi/build/Smdn.MSBuild.DefineConstants.NETSdkApi.targets | |
@@ -8,6 +8,22 @@ SPDX-License-Identifier: MIT | |
Name="AddNETSdkApiDefineConstants" | |
DependsOnTargets="AddImplicitDefineConstants" | |
BeforeTargets="CoreCompile" | |
+ > | |
+ <CallTarget Targets="ListNETSdkAvailableApiName"> | |
+ <Output TaskParameter="TargetOutputs" ItemName="_NETSdkAvailableApiSymbol" /> | |
+ </CallTarget> | |
+ | |
+ <!-- <Message Text="@(_NETSdkAvailableApiSymbol, ', ')" Importance="high" /> --> | |
+ | |
+ <PropertyGroup> | |
+ <DefineConstants>$(DefineConstants);@(_NETSdkAvailableApiSymbol, ';')</DefineConstants> | |
+ </PropertyGroup> | |
+ </Target> | |
+ | |
+ <!-- ref: list of preprocessor symbols for .NET target frameworks: https://docs.microsoft.com/ja-jp/dotnet/standard/frameworks --> | |
+ <Target | |
+ Name="ListNETSdkAvailableApiName" | |
+ Returns="@(NETSdkAvailableApiSymbol)" | |
> | |
<!-- NET46_OR_GREATER || NETSTANDARD1_3_OR_GREATER || NETCOREAPP1_0_OR_GREATER || NET5_0_OR_GREATER --> | |
<ItemGroup Condition=" | |
@@ -22,6 +38,16 @@ SPDX-License-Identifier: MIT | |
<_NETSdkAvailableApiName Include="System.Threading.Tasks.Task.FromCanceled"/> | |
</ItemGroup> | |
+ <!-- NET461_OR_GREATER || NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_0_OR_GREATER || NET5_0_OR_GREATER --> | |
+ <ItemGroup Condition=" | |
+ $([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNET461_OR_GREATER\b')) Or | |
+ $([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNETSTANDARD2_0_OR_GREATER\b')) Or | |
+ $([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNETCOREAPP2_0_OR_GREATER\b')) Or | |
+ $([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNET5_0_OR_GREATER\b')) | |
+ "> | |
+ <_NETSdkAvailableApiName Include="System.IAsyncDisposable"/> | |
+ </ItemGroup> | |
+ | |
<!-- NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_0_OR_GREATER || NET5_0_OR_GREATER --> | |
<ItemGroup Condition=" | |
$([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNETFRAMEWORK\b')) Or | |
@@ -37,6 +63,8 @@ SPDX-License-Identifier: MIT | |
<_NETSdkAvailableApiName Include="System.Diagnostics.Process"/> | |
<_NETSdkAvailableApiName Include="System.IO.Stream.Close"/> | |
<_NETSdkAvailableApiName Include="System.Net.NetworkInformation.PhysicalAddress"/> | |
+ <_NETSdkAvailableApiName Include="System.Runtime.Serialization.Formatter.Binary"/> | |
+ <_NETSdkAvailableApiName Include="System.Runtime.Serialization.SerializationBinder"/> | |
<_NETSdkAvailableApiName Include="System.Security.Cryptography.HashAlgorithm.Clear"/> | |
</ItemGroup> | |
@@ -66,6 +94,7 @@ SPDX-License-Identifier: MIT | |
<_NETSdkAvailableApiName Include="System.ArraySegment.Slice"/> | |
<_NETSdkAvailableApiName Include="System.String.EndsWith(char)"/> | |
<_NETSdkAvailableApiName Include="System.String.Split(char)"/> | |
+ <_NETSdkAvailableApiName Include="System.String.Split(string)"/> | |
<_NETSdkAvailableApiName Include="System.String.StartsWith(char)"/> | |
<_NETSdkAvailableApiName Include="System.Collections.Generic.KeyValuePair.Create"/> | |
<_NETSdkAvailableApiName Include="System.IO.Path.GetRelativePath"/> | |
@@ -77,14 +106,18 @@ SPDX-License-Identifier: MIT | |
$([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNETCOREAPP2_1_OR_GREATER\b')) Or | |
$([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNET5_0_OR_GREATER\b')) | |
"> | |
- <_NETSdkAvailableApiName Include="System.INumber.Parse(ReadOnlySpan_Of_Char)"/> | |
- <_NETSdkAvailableApiName Include="System.INumber.TryParse(ReadOnlySpan_Of_Char)"/> | |
- <_NETSdkAvailableApiName Include="System.String.ctor(ReadOnlySpan_Of_Char)"/> | |
+ <_NETSdkAvailableApiName Include="System.INumber.Parse(ReadOnlySpan<Char>)"/> | |
+ <_NETSdkAvailableApiName Include="System.INumber.TryParse(ReadOnlySpan<Char>)"/> | |
+ <_NETSdkAvailableApiName Include="System.String.ctor(ReadOnlySpan<Char>)"/> | |
<_NETSdkAvailableApiName Include="System.String.Create"/> | |
<_NETSdkAvailableApiName Include="System.String.Contains(char)"/> | |
- <_NETSdkAvailableApiName Include="System.IO.Stream.ReadAsync(Memory_Of_Byte)"/> | |
- <_NETSdkAvailableApiName Include="System.IO.Stream.WriteAsync(ReadOnlyMemory_Of_Byte)"/> | |
- <_NETSdkAvailableApiName Include="System.Text.StringBuilder.Append(ReadOnlySpan_Of_Char)"/> | |
+ <_NETSdkAvailableApiName Include="System.IO.Path.Join"/> | |
+ <_NETSdkAvailableApiName Include="System.IO.Path.TryJoin"/> | |
+ <_NETSdkAvailableApiName Include="System.IO.Stream.Read(Span<Byte>)"/> | |
+ <_NETSdkAvailableApiName Include="System.IO.Stream.ReadAsync(Memory<Byte>)"/> | |
+ <_NETSdkAvailableApiName Include="System.IO.Stream.Write(ReadOnlySpan<Byte>)"/> | |
+ <_NETSdkAvailableApiName Include="System.IO.Stream.WriteAsync(ReadOnlyMemory<Byte>)"/> | |
+ <_NETSdkAvailableApiName Include="System.Text.StringBuilder.Append(ReadOnlySpan<Char>)"/> | |
<_NETSdkAvailableApiName Include="System.Threading.Tasks.ValueTask"/> | |
</ItemGroup> | |
@@ -104,25 +137,49 @@ SPDX-License-Identifier: MIT | |
$([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNETCOREAPP3_0_OR_GREATER\b')) Or | |
$([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNET5_0_OR_GREATER\b')) | |
"> | |
- <_NETSdkAvailableApiName Include="System.Text.StringBuilder.Append(ReadOnlyMemory_Of_Char)"/> | |
+ <_NETSdkAvailableApiName Include="System.Text.StringBuilder.Append(ReadOnlyMemory<Char>)"/> | |
</ItemGroup> | |
<!-- NET5_0_OR_GREATER --> | |
<ItemGroup Condition=" | |
$([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNET5_0_OR_GREATER\b')) | |
"> | |
+ <_NETSdkAvailableApiName Include="System.Enum.IsDefined<TEnum>"/> | |
+ <_NETSdkAvailableApiName Include="System.StringSplitOptions.TrimEntries"/> | |
<_NETSdkAvailableApiName Include="System.Buffers.SequenceReader.UnreadSequence"/> | |
+ <_NETSdkAvailableApiName Include="System.Collections.Generic.IReadOnlySet"/> | |
+ <_NETSdkAvailableApiName Include="System.Runtime.CompilerServices.IsExternalInit"/> | |
+ <_NETSdkAvailableApiName Include="System.Threading.Tasks.ValueTask.CompletedTask"/> | |
<_NETSdkAvailableApiName Include="System.Threading.Tasks.ValueTask.FromCanceled"/> | |
+ <_NETSdkAvailableApiName Include="System.Threading.Tasks.ValueTask.FromResult"/> | |
+ </ItemGroup> | |
+ | |
+ <!-- NET6_0_OR_GREATER --> | |
+ <ItemGroup Condition=" | |
+ $([System.Text.RegularExpressions.Regex]::IsMatch('$(DefineConstants)', '\bNET6_0_OR_GREATER\b')) | |
+ "> | |
+ <_NETSdkAvailableApiName Include="System.String.Create(IFormatProvider)"/> | |
</ItemGroup> | |
<ItemGroup> | |
<_NETSdkAvailableApiName Update="@(_NETSdkAvailableApiName)"> | |
- <Constant>$([System.String]::new('%(Identity)').ToUpperInvariant().Replace('.', '_').Replace('(', '_').Replace(')', ''))</Constant> | |
+ <Constant>$( | |
+ [System.String]::new('%(Identity)') | |
+ .Replace('.', '_') | |
+ .Replace('(', '_') | |
+ .Replace(')', '') | |
+ .Replace('<', '_OF_') | |
+ .Replace('>', '') | |
+ .ToUpperInvariant() | |
+ )</Constant> | |
</_NETSdkAvailableApiName> | |
</ItemGroup> | |
- <PropertyGroup Condition="0 < @(_NETSdkAvailableApiName->Count())"> | |
- <DefineConstants>$(DefineConstants);@(_NETSdkAvailableApiName->Metadata('Constant'), ';')</DefineConstants> | |
- </PropertyGroup> | |
+ <ItemGroup> | |
+ <NETSdkAvailableApiSymbol | |
+ Condition="0 < @(_NETSdkAvailableApiName->Count())" | |
+ Include="@(_NETSdkAvailableApiName->Metadata('Constant'))" | |
+ /> | |
+ </ItemGroup> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment