Add shared props/targets and update per rules

This commit is contained in:
James Jackson-South 2020-11-30 18:38:17 +00:00
Родитель d9c000b35b
Коммит 1c47614d9d
18 изменённых файлов: 473 добавлений и 205 удалений

21
Directory.Build.props Normal file
Просмотреть файл

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--
Directory.Build.props is automatically picked up and imported by
Microsoft.Common.props. This file needs to exist, even if empty so that
files in the parent directory tree, with the same name, are not imported
instead. They import fairly early and only Sdk.props will have been imported
beforehand. We also don't need to add ourselves to MSBuildAllProjects, as
that is done by the file that imports us.
-->
<PropertyGroup>
<!-- This MUST be defined before importing props. -->
<SixLaborsSolutionDirectory>$(MSBuildThisFileDirectory)</SixLaborsSolutionDirectory>
</PropertyGroup>
<!-- Import the shared global .props file -->
<Import Project="$(SixLaborsSolutionDirectory)msbuild\props\SixLabors.Global.props"/>
</Project>

16
Directory.Build.targets Normal file
Просмотреть файл

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--
Directory.Build.targets is automatically picked up and imported by
Microsoft.Common.targets. This file needs to exist, even if empty so that
files in the parent directory tree, with the same name, are not imported
instead. They import fairly late and most other props/targets will have been
imported beforehand. We also don't need to add ourselves to
MSBuildAllProjects, as that is done by the file that imports us.
-->
<!-- Import the global .targets file -->
<Import Project="$(SixLaborsSolutionDirectory)msbuild\targets\SixLabors.Global.targets"/>
</Project>

Просмотреть файл

@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_root", "_root", "{27502888
ci-build.ps1 = ci-build.ps1
ci-test.ps1 = ci-test.ps1
codecov.yml = codecov.yml
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
LICENSE = LICENSE
README.md = README.md
SixLabors.ruleset = SixLabors.ruleset
@ -35,10 +37,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{07706BC0-CA04-4558-A005-3F9FA7D9933C}"
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
src\Directory.Build.targets = src\Directory.Build.targets
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{478B60EE-3651-4B39-83BD-528C428AC628}"
ProjectSection(SolutionItems) = preProject
tests\coverlet.runsettings = tests\coverlet.runsettings
tests\Directory.Build.props = tests\Directory.Build.props
tests\Directory.Build.targets = tests\Directory.Build.targets
EndProjectSection
EndProject
Global

Просмотреть файл

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--
Directory.Build.props is automatically picked up and imported by
Microsoft.Common.props. This file needs to exist, even if empty so that
files in the parent directory tree, with the same name, are not imported
instead. They import fairly early and only Sdk.props will have been imported
beforehand. We also don't need to add ourselves to MSBuildAllProjects, as
that is done by the file that imports us.
-->
<!-- Compilation settings that explicitly differ from the Sdk.props/targets defaults -->
<PropertyGroup>
<LangVersion Condition="'$(LangVersion)' == ''">8.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Features>strict;IOperation</Features>
<HighEntropyVA>true</HighEntropyVA>
<NeutralLanguage>en</NeutralLanguage>
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
<DebugType>portable</DebugType>
<DebugType Condition="'$(codecov)' != ''">full</DebugType>
<NullableContextOptions>disable</NullableContextOptions>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>
<!-- Required restore feeds. -->
<PropertyGroup>
<RestoreSources>
$(RestoreSources);
https://api.nuget.org/v3/index.json;
https://www.myget.org/F/sixlabors/api/v3/index.json;
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json;
https://f.feedz.io/marcorossignoli/coverletunofficial/nuget/index.json;
</RestoreSources>
</PropertyGroup>
<!-- Standardize build output location. -->
<PropertyGroup>
<BaseArtifactsPath>$(SixLaborsSolutionDirectory)artifacts/</BaseArtifactsPath>
<BaseArtifactsPathSuffix>$(SixLaborsProjectCategory)/$(MSBuildProjectName)</BaseArtifactsPathSuffix>
<BaseIntermediateOutputPath>$(BaseArtifactsPath)obj/$(BaseArtifactsPathSuffix)/</BaseIntermediateOutputPath>
<BaseOutputPath>$(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/</BaseOutputPath>
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(BaseArtifactsPathSuffix)/$(Configuration)/</PackageOutputPath>
</PropertyGroup>
<!-- Public key definition for signing assemblies. -->
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)..\..\SixLabors.snk</AssemblyOriginatorKeyFile>
<SixLaborsPublicKey>00240000048000009400000006020000002400005253413100040000010001000147e6fe6766715eec6cfed61f1e7dcdbf69748a3e355c67e9d8dfd953acab1d5e012ba34b23308166fdc61ee1d0390d5f36d814a6091dd4b5ed9eda5a26afced924c683b4bfb4b3d64b0586a57eff9f02b1f84e3cb0ddd518bd1697f2c84dcbb97eb8bb5c7801be12112ed0ec86db934b0e9a5171e6bb1384b6d2f7d54dfa97</SixLaborsPublicKey>
<UseSharedCompilation>true</UseSharedCompilation>
</PropertyGroup>
<!-- Package references and additional files which are consumed by all projects. -->
<ItemGroup>
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" IsImplicitlyDefined="true" />
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" Version="1.1.118" IsImplicitlyDefined="true" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\..\stylecop.json" />
</ItemGroup>
<!--Define OS platform conditions and constants.
https://docs.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2019#msbuild-property-functions
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform?view=net-5.0#properties
-->
<PropertyGroup>
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
<IsFreeBSD Condition="$([MSBuild]::IsOSPlatform('FreeBSD'))">true</IsFreeBSD>
</PropertyGroup>
<Choose>
<When Condition="'$(IsWindows)'=='true'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);OS_WINDOWS</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(IsOSX)'=='true'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);OS_OSX</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(IsLinux)'=='true'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);OS_LINUX</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(IsFreeBSD)'=='true'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);OS_FREEBSD</DefineConstants>
</PropertyGroup>
</When>
</Choose>
<!-- Define target framework specific constants.
https://apisof.net/
+===================+=======+==========+=====================+=============+=================+====================+==============+=========+============|
| SUPPORTS | MATHF | HASHCODE | EXTENDED_INTRINSICS | SPAN_STREAM | ENCODING_STRING | RUNTIME_INTRINSICS | CODECOVERAGE | HOTPATH | CREATESPAN |
+===================+=======+==========+=====================+=============+=================+====================+==============+=========|============|
| netcoreapp3.1 | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| netcoreapp2.1 | Y | Y | Y | Y | Y | N | Y | N | Y |
| netcoreapp2.0 | Y | N | N | N | N | N | Y | N | Y |
| netstandard2.1 | Y | Y | N | Y | Y | N | Y | N | Y |
| netstandard2.0 | N | N | N | N | N | N | Y | N | N |
| netstandard1.3 | N | N | N | N | N | N | N | N | N |
| net472 | N | N | Y | N | N | N | Y | N | N |
+===================+=======+==========+=====================+=============+=================+====================+==============+=========|============|
-->
<Choose>
<When Condition="'$(TargetFramework)' == 'net472'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PropertyGroup>
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
</PropertyGroup>
</When>
<When Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<!--NETCORE 3.1. NET5.0, and future versions will fallback to this as the closest target.-->
<PropertyGroup>
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_RUNTIME_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_HOTPATH</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
</PropertyGroup>
</When>
</Choose>
</Project>

Просмотреть файл

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Compilation and build location settings. -->
<PropertyGroup>
<SixLaborsProjectCategory>src</SixLaborsProjectCategory>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(MSBuildThisFileDirectory)..\..\SixLabors.ruleset</CodeAnalysisRuleSet>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<!-- Add deterministic builds in CI .-->
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>
<!-- Common NuGet package settings. -->
<PropertyGroup>
<Copyright>Copyright © Six Labors</Copyright>
<Authors>Six Labors and contributors</Authors>
<Company>Six Labors</Company>
<VersionPrefix>0.0.1</VersionPrefix>
<VersionPrefix Condition="'$(packageversion)' != ''">$(PackageVersion)</VersionPrefix>
<VersionSuffix></VersionSuffix>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<RepositoryType>git</RepositoryType>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<!-- Package references and additional files which are consumed by src projects -->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" IsImplicitlyDefined="true" />
<PackageReference Include="MinVer" PrivateAssets="All" Version="2.3.1" IsImplicitlyDefined="true"/>
</ItemGroup>
<!--MinVer Properties for versioning-->
<PropertyGroup>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerVerbosity>normal</MinVerVerbosity>
</PropertyGroup>
</Project>

Просмотреть файл

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Compilation and build location settings. -->
<PropertyGroup>
<SixLaborsProjectCategory>tests</SixLaborsProjectCategory>
<IsTestProject Condition="'$(IsTestProject)' == ''">true</IsTestProject>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet Condition="'$(CodeAnalysisRuleSet)' == ''">$(MSBuildThisFileDirectory)..\..\SixLabors.Tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<!-- Package references and additional files which are consumed by test projects -->
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<!--
Setup-dotnet action does not have an x86 runner. You have to use separate SDKs
https://github.com/actions/setup-dotnet/issues/72
-->
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" IsImplicitlyDefined="true" />
<PackageReference Include="xunit" Version="2.4.1" IsImplicitlyDefined="true" />
<PackageReference Include="coverlet.collector"
Version="3.0.0-preview.9"
PrivateAssets="All"
IsImplicitlyDefined="true"
Condition="'$(codecov)' == 'true'"/>
<!-- Maximum compatible version for xunit with netcore 2.0 -->
<PackageReference Include="Microsoft.NET.Test.Sdk"
Version="16.2.0"
IsImplicitlyDefined="true"
Condition="'$(TargetFramework)' == 'netcoreapp2.0'"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"
Version="16.8.0"
IsImplicitlyDefined="true"
Condition="'$(TargetFramework)' != 'netcoreapp2.0'"/>
<!-- Maximum compatible version with net46 or net472-->
<PackageReference Include="xunit.runner.visualstudio"
Version="2.4.1"
IsImplicitlyDefined="true"
Condition="'$(TargetFramework)' == 'net46' OR '$(TargetFramework)' == 'net472' OR '$(TargetFramework)' == 'netcoreapp2.0'" />
<PackageReference Include="xunit.runner.visualstudio"
Version="2.4.3"
IsImplicitlyDefined="true"
Condition="'$(TargetFramework)' != 'net46' AND '$(TargetFramework)' != 'net472' AND '$(TargetFramework)' != 'netcoreapp2.0'" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--
Directory.Build.targets is automatically picked up and imported by
Microsoft.Common.targets. This file needs to exist, even if empty so that
files in the parent directory tree, with the same name, are not imported
instead. They import fairly late and most other props/targets will have been
imported beforehand. We also don't need to add ourselves to
MSBuildAllProjects, as that is done by the file that imports us.
-->
<!--
Allow "InternalsVisibleTo" usage in src props file.
Usage:
<InternalsVisibleTo Include="[ASSEMBLY_NAME]" Key="$(SixLaborsPublicKey)" />
-->
<PropertyGroup>
<GeneratedInternalsVisibleToFile Condition="'$(GeneratedInternalsVisibleToFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile>
</PropertyGroup>
<ItemDefinitionGroup>
<InternalsVisibleTo>
<Visible>false</Visible>
</InternalsVisibleTo>
</ItemDefinitionGroup>
<Target Name="GenerateInternalsVisibleTo"
BeforeTargets="CoreCompile"
DependsOnTargets="PrepareForBuild;CoreGenerateInternalsVisibleTo"
Condition="'@(InternalsVisibleTo)' != ''" />
<Target Name="CoreGenerateInternalsVisibleTo"
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
Inputs="$(MSBuildAllProjects)"
Outputs="$(GeneratedInternalsVisibleToFile)">
<CreateItem
Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"
AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity)"
Condition="'%(InternalsVisibleTo.Key)' == ''">
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
</CreateItem>
<CreateItem
Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"
AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity), PublicKey=%(InternalsVisibleTo.Key)"
Condition="'%(InternalsVisibleTo.Key)' != ''">
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
</CreateItem>
<WriteCodeFragment AssemblyAttributes="@(InternalsVisibleToAttribute)" Language="$(Language)" OutputFile="$(GeneratedInternalsVisibleToFile)">
<Output TaskParameter="OutputFile" ItemName="Compile" />
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
</WriteCodeFragment>
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Empty target so that `dotnet test` will work on the solution -->
<!-- https://github.com/Microsoft/vstest/issues/411 -->
<Target Name="VSTest" Condition="'$(IsTestProject)' == 'true'"/>
<ItemGroup>
<!-- Shared config files that have to exist at root level. -->
<SixLaborsConfigFilesToCopy Include="$(MSBuildThisFileDirectory)..\..\.editorconfig;$(MSBuildThisFileDirectory)..\..\.gitattributes" />
</ItemGroup>
<!-- Copy the config files on src build. -->
<Target Name="SixLaborsCopyConfigFiles" BeforeTargets="Build" Condition="'$(SixLaborsDisableConfigCopy)' == ''">
<Copy SourceFiles="@(SixLaborsConfigFilesToCopy)"
SkipUnchangedFiles = "true"
DestinationFolder="$(SixLaborsSolutionDirectory)" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Empty for now. -->
</Project>

10
src/Directory.Build.props Normal file
Просмотреть файл

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Import the shared src .props file -->
<Import Project="$(MSBuildThisFileDirectory)..\msbuild\props\SixLabors.Src.props"/>
<!-- Import the solution .props file. -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props"/>
</Project>

Просмотреть файл

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Import the solution .targets file. -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props"/>
<!-- Import the shared src .targets file -->
<Import Project="$(SixLaborsSolutionDirectory)msbuild\targets\SixLabors.Src.targets"/>
</Project>

Просмотреть файл

@ -32,9 +32,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Abs(float f)
{
return Math.Abs(f);
}
=> Math.Abs(f);
/// <summary>
/// Returns the angle whose tangent is the quotient of two specified numbers.
@ -54,9 +52,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Atan2(float y, float x)
{
return (float)Math.Atan2(y, x);
}
=> (float)Math.Atan2(y, x);
/// <summary>
/// Returns the smallest integral value that is greater than or equal to the specified single-precision floating-point number.
@ -70,9 +66,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Ceiling(float f)
{
return (float)Math.Ceiling(f);
}
=> (float)Math.Ceiling(f);
/// <summary>
/// Returns the cosine of the specified angle.
@ -84,9 +78,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Cos(float f)
{
return (float)Math.Cos(f);
}
=> (float)Math.Cos(f);
/// <summary>
/// Returns e raised to the specified power.
@ -99,9 +91,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Exp(float f)
{
return (float)Math.Exp(f);
}
=> (float)Math.Exp(f);
/// <summary>
/// Returns the largest integer less than or equal to the specified single-precision floating-point number.
@ -114,9 +104,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Floor(float f)
{
return (float)Math.Floor(f);
}
=> (float)Math.Floor(f);
/// <summary>
/// Returns the larger of two single-precision floating-point numbers.
@ -130,9 +118,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Max(float val1, float val2)
{
return Math.Max(val1, val2);
}
=> Math.Max(val1, val2);
/// <summary>
/// Returns the smaller of two single-precision floating-point numbers.
@ -146,9 +132,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Min(float val1, float val2)
{
return Math.Min(val1, val2);
}
=> Math.Min(val1, val2);
/// <summary>
/// Returns a specified number raised to the specified power.
@ -158,9 +142,7 @@ namespace System
/// <returns>The number <paramref name="x" /> raised to the power <paramref name="y" />.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Pow(float x, float y)
{
return (float)Math.Pow(x, y);
}
=> (float)Math.Pow(x, y);
/// <summary>
/// Rounds a single-precision floating-point value to the nearest integral value.
@ -173,9 +155,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Round(float f)
{
return (float)Math.Round(f);
}
=> (float)Math.Round(f);
/// <summary>
/// Rounds a single-precision floating-point value to the nearest integer.
@ -192,9 +172,7 @@ namespace System
/// <paramref name="mode" /> is not a valid value of <see cref="T:System.MidpointRounding" />.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Round(float f, MidpointRounding mode)
{
return (float)Math.Round(f, mode);
}
=> (float)Math.Round(f, mode);
/// <summary>
/// Returns the sine of the specified angle.
@ -207,9 +185,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Sin(float f)
{
return (float)Math.Sin(f);
}
=> (float)Math.Sin(f);
/// <summary>
/// Returns the square root of a specified number.
@ -224,9 +200,7 @@ namespace System
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Sqrt(float f)
{
return (float)Math.Sqrt(f);
}
=> (float)Math.Sqrt(f);
}
}
#endif

Просмотреть файл

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<!--Disable config copy. This solution only.-->
<SixLaborsDisableConfigCopy>true</SixLaborsDisableConfigCopy>
</PropertyGroup>
<!-- Import the shared tests .props file -->
<Import Project="$(MSBuildThisFileDirectory)..\msbuild\props\SixLabors.Tests.props"/>
<!-- Import the solution .props file. -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props"/>
</Project>

Просмотреть файл

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!-- Import the shared tests .targets file -->
<Import Project="$(MSBuildThisFileDirectory)..\msbuild\targets\SixLabors.Tests.targets"/>
<!-- Import the solution .targets file. -->
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets"/>
</Project>

Просмотреть файл

@ -145,9 +145,7 @@ namespace SharedInfrastructure.Tests
[Fact]
public void MustBeLessThan_IsLess_ThrowsNoException()
{
DebugGuard.MustBeLessThan(0, 1, "myParamName");
}
=> DebugGuard.MustBeLessThan(0, 1, "myParamName");
[Theory]
[InlineData(2, 1)]
@ -165,9 +163,7 @@ namespace SharedInfrastructure.Tests
[InlineData(0, 1)]
[InlineData(1, 1)]
public void MustBeLessThanOrEqualTo_IsLessOrEqual_ThrowsNoException(int value, int max)
{
DebugGuard.MustBeLessThanOrEqualTo(value, max, "myParamName");
}
=> DebugGuard.MustBeLessThanOrEqualTo(value, max, "myParamName");
[Fact]
public void MustBeLessThanOrEqualTo_IsGreater_ThrowsNoException()
@ -180,9 +176,7 @@ namespace SharedInfrastructure.Tests
[Fact]
public void MustBeGreaterThan_IsGreater_ThrowsNoException()
{
DebugGuard.MustBeGreaterThan(2, 1, "myParamName");
}
=> DebugGuard.MustBeGreaterThan(2, 1, "myParamName");
[Theory]
[InlineData(1, 2)]
@ -200,9 +194,7 @@ namespace SharedInfrastructure.Tests
[InlineData(2, 1)]
[InlineData(1, 1)]
public void MustBeGreaterThanOrEqualTo_IsGreaterOrEqual_ThrowsNoException(int value, int min)
{
DebugGuard.MustBeGreaterThanOrEqualTo(value, min, "myParamName");
}
=> DebugGuard.MustBeGreaterThanOrEqualTo(value, min, "myParamName");
[Fact]
public void MustBeGreaterThanOrEqualTo_IsLess_ThrowsNoException()
@ -218,9 +210,7 @@ namespace SharedInfrastructure.Tests
[InlineData(new int[] { 1, 2 }, 1)]
[InlineData(new int[] { 1, 2 }, 2)]
public void MustBeSizedAtLeast_Array_LengthIsGreaterOrEqual_ThrowsNoException(int[] value, int minLength)
{
DebugGuard.MustBeSizedAtLeast<int>(value, minLength, "myParamName");
}
=> DebugGuard.MustBeSizedAtLeast<int>(value, minLength, "myParamName");
[Fact]
public void MustBeSizedAtLeast_Array_LengthIsLess_ThrowsException()

Просмотреть файл

@ -125,9 +125,7 @@ namespace SharedInfrastructure.Tests
[Fact]
public void MustBeLessThan_IsLess_ThrowsNoException()
{
Guard.MustBeLessThan(0, 1, "myParamName");
}
=> Guard.MustBeLessThan(0, 1, "myParamName");
[Theory]
[InlineData(2, 1)]
@ -145,9 +143,7 @@ namespace SharedInfrastructure.Tests
[InlineData(0, 1)]
[InlineData(1, 1)]
public void MustBeLessThanOrEqualTo_IsLessOrEqual_ThrowsNoException(int value, int max)
{
Guard.MustBeLessThanOrEqualTo(value, max, "myParamName");
}
=> Guard.MustBeLessThanOrEqualTo(value, max, "myParamName");
[Fact]
public void MustBeLessThanOrEqualTo_IsGreater_ThrowsNoException()
@ -160,10 +156,7 @@ namespace SharedInfrastructure.Tests
}
[Fact]
public void MustBeGreaterThan_IsGreater_ThrowsNoException()
{
Guard.MustBeGreaterThan(2, 1, "myParamName");
}
public void MustBeGreaterThan_IsGreater_ThrowsNoException() => Guard.MustBeGreaterThan(2, 1, "myParamName");
[Theory]
[InlineData(1, 2)]
@ -181,9 +174,7 @@ namespace SharedInfrastructure.Tests
[InlineData(2, 1)]
[InlineData(1, 1)]
public void MustBeGreaterThanOrEqualTo_IsGreaterOrEqual_ThrowsNoException(int value, int min)
{
Guard.MustBeGreaterThanOrEqualTo(value, min, "myParamName");
}
=> Guard.MustBeGreaterThanOrEqualTo(value, min, "myParamName");
[Fact]
public void MustBeGreaterThanOrEqualTo_IsLess_ThrowsNoException()
@ -200,9 +191,7 @@ namespace SharedInfrastructure.Tests
[InlineData(2, 1, 3)]
[InlineData(3, 1, 3)]
public void MustBeBetweenOrEqualTo_IsBetweenOrEqual_ThrowsNoException(int value, int min, int max)
{
Guard.MustBeBetweenOrEqualTo(value, min, max, "myParamName");
}
=> Guard.MustBeBetweenOrEqualTo(value, min, max, "myParamName");
[Theory]
[InlineData(0, 1, 3)]
@ -220,9 +209,7 @@ namespace SharedInfrastructure.Tests
[InlineData(2, 1)]
[InlineData(2, 2)]
public void MustBeSizedAtLeast_Array_LengthIsGreaterOrEqual_ThrowsNoException(int valueLength, int minLength)
{
Guard.MustBeSizedAtLeast<int>(new int[valueLength], minLength, "myParamName");
}
=> Guard.MustBeSizedAtLeast<int>(new int[valueLength], minLength, "myParamName");
[Fact]
public void MustBeSizedAtLeast_Array_LengthIsLess_ThrowsException()

Просмотреть файл

@ -10,86 +10,58 @@ namespace SharedInfrastructure.Tests
{
[Fact]
public void MathF_PI_Is_Equal()
{
Assert.Equal(MathF.PI, (float)Math.PI);
}
=> Assert.Equal(MathF.PI, (float)Math.PI);
[Fact]
public void MathF_Ceililng_Is_Equal()
{
Assert.Equal(MathF.Ceiling(0.3333F), (float)Math.Ceiling(0.3333F));
}
=> Assert.Equal(MathF.Ceiling(0.3333F), (float)Math.Ceiling(0.3333F));
[Fact]
public void MathF_Cos_Is_Equal()
{
Assert.Equal(MathF.Cos(0.3333F), (float)Math.Cos(0.3333F));
}
=> Assert.Equal(MathF.Cos(0.3333F), (float)Math.Cos(0.3333F));
[Fact]
public void MathF_Abs_Is_Equal()
{
Assert.Equal(MathF.Abs(-0.3333F), (float)Math.Abs(-0.3333F));
}
=> Assert.Equal(MathF.Abs(-0.3333F), (float)Math.Abs(-0.3333F));
[Fact]
public void MathF_Atan2_Is_Equal()
{
Assert.Equal(MathF.Atan2(1.2345F, 1.2345F), (float)Math.Atan2(1.2345F, 1.2345F));
}
=> Assert.Equal(MathF.Atan2(1.2345F, 1.2345F), (float)Math.Atan2(1.2345F, 1.2345F));
[Fact]
public void MathF_Exp_Is_Equal()
{
Assert.Equal(MathF.Exp(1.2345F), (float)Math.Exp(1.2345F));
}
=> Assert.Equal(MathF.Exp(1.2345F), (float)Math.Exp(1.2345F));
[Fact]
public void MathF_Floor_Is_Equal()
{
Assert.Equal(MathF.Floor(1.2345F), (float)Math.Floor(1.2345F));
}
=> Assert.Equal(MathF.Floor(1.2345F), (float)Math.Floor(1.2345F));
[Fact]
public void MathF_Min_Is_Equal()
{
Assert.Equal(MathF.Min(1.2345F, 5.4321F), (float)Math.Min(1.2345F, 5.4321F));
}
=> Assert.Equal(MathF.Min(1.2345F, 5.4321F), (float)Math.Min(1.2345F, 5.4321F));
[Fact]
public void MathF_Max_Is_Equal()
{
Assert.Equal(MathF.Max(1.2345F, 5.4321F), (float)Math.Max(1.2345F, 5.4321F));
}
=> Assert.Equal(MathF.Max(1.2345F, 5.4321F), (float)Math.Max(1.2345F, 5.4321F));
[Fact]
public void MathF_Pow_Is_Equal()
{
Assert.Equal(MathF.Pow(1.2345F, 5.4321F), (float)Math.Pow(1.2345F, 5.4321F));
}
=> Assert.Equal(MathF.Pow(1.2345F, 5.4321F), (float)Math.Pow(1.2345F, 5.4321F));
[Fact]
public void MathF_Round_Is_Equal()
{
Assert.Equal(MathF.Round(1.2345F), (float)Math.Round(1.2345F));
}
=> Assert.Equal(MathF.Round(1.2345F), (float)Math.Round(1.2345F));
[Fact]
public void MathF_Round_With_Midpoint_Is_Equal()
{
Assert.Equal(MathF.Round(1.2345F, MidpointRounding.AwayFromZero), (float)Math.Round(1.2345F, MidpointRounding.AwayFromZero));
}
=> Assert.Equal(MathF.Round(1.2345F, MidpointRounding.AwayFromZero), (float)Math.Round(1.2345F, MidpointRounding.AwayFromZero));
[Fact]
public void MathF_Sin_Is_Equal()
{
Assert.Equal(MathF.Sin(1.2345F), (float)Math.Sin(1.2345F));
}
=> Assert.Equal(MathF.Sin(1.2345F), (float)Math.Sin(1.2345F));
[Fact]
public void MathF_Sqrt_Is_Equal()
{
Assert.Equal(MathF.Sqrt(2F), (float)Math.Sqrt(2F));
}
=> Assert.Equal(MathF.Sqrt(2F), (float)Math.Sqrt(2F));
}
}

Просмотреть файл

@ -1,101 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;netcoreapp2.0;net472;net46</TargetFrameworks>
<AssemblyName>SharedInfrastructure.Tests</AssemblyName>
<RootNamespace>SharedInfrastructure.Tests</RootNamespace>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>..\..\SixLabors.Tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<!--
https://apisof.net/
+===================+=======+==========+=====================+=============+=================+====================+==============+=========+============|
| SUPPORTS | MATHF | HASHCODE | EXTENDED_INTRINSICS | SPAN_STREAM | ENCODING_STRING | RUNTIME_INTRINSICS | CODECOVERAGE | HOTPATH | CREATESPAN |
+===================+=======+==========+=====================+=============+=================+====================+==============+=========|============|
| netcoreapp3.1 | Y | Y | Y | Y | Y | Y | Y | Y | Y |
| netcoreapp2.1 | Y | Y | Y | Y | Y | N | Y | N | Y |
| netcoreapp2.0 | Y | N | N | N | N | N | Y | N | Y |
| netstandard2.1 | Y | Y | N | Y | Y | N | Y | N | Y |
| netstandard2.0 | N | N | N | N | N | N | Y | N | N |
| netstandard1.3 | N | N | N | N | N | N | N | N | N |
| net472 | N | N | Y | N | N | N | Y | N | N |
+===================+=======+==========+=====================+=============+=================+====================+==============+=========|============|
-->
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_RUNTIME_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_HOTPATH</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<!--dotnet tools does not have an x86 runner. You have to use separate SDKs-->
<!--https://github.com/actions/setup-dotnet/issues/72-->
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<!--Don't update the SDK. It causes xunit to break for netcore 2.0-->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp2.0' ">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="1.3.0" PrivateAssets="All"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<AdditionalFiles Include="..\..\stylecop.json" />
</ItemGroup>
<ItemGroup Condition=" ('$(TargetFramework)' != 'netcoreapp3.1') AND '$(TargetFramework)' != 'netcoreapp2.1' ">
<PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('netstandard')) ">