Skip to content

Commit 4756e05

Browse files
authored
Merge pull request #18 from synercoder/develop
Broader support
2 parents aed8b53 + 0324d87 commit 4756e05

11 files changed

+146
-24
lines changed

Diff for: .github/workflows/dotnet-core.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup .NET Core
3434
uses: actions/setup-dotnet@v1
3535
with:
36-
dotnet-version: 3.1.x
36+
dotnet-version: 5.0.x
3737
- name: Restore
3838
run: dotnet restore
3939
- name: Build
@@ -73,7 +73,7 @@ jobs:
7373
- name: Setup .NET Core
7474
uses: actions/setup-dotnet@v1
7575
with:
76-
dotnet-version: 3.1.x
76+
dotnet-version: 5.0.x
7777
- name: Create Release NuGet package
7878
run: |
7979
arrTag=(${GITHUB_REF//\// })

Diff for: Directory.Build.props

+72-10
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,79 @@
4141
</PropertyGroup>
4242

4343
<PropertyGroup>
44-
<LangVersion>8.0</LangVersion>
44+
<LangVersion>9.0</LangVersion>
4545
</PropertyGroup>
4646

47-
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
48-
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
49-
</PropertyGroup>
50-
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
51-
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
52-
</PropertyGroup>
53-
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
54-
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
55-
</PropertyGroup>
47+
<!-- Define target framework specific constants.
48+
https://apisof.net/
49+
+===================+=======+==========+=====================+=============+=================+====================+==============+=========+============|===============|
50+
| SUPPORTS | MATHF | HASHCODE | EXTENDED_INTRINSICS | SPAN_STREAM | ENCODING_STRING | RUNTIME_INTRINSICS | CODECOVERAGE | HOTPATH | CREATESPAN | BITOPERATIONS |
51+
+===================+=======+==========+=====================+=============+=================+====================+==============+=========|============|===============|
52+
| >=netcoreapp3.1 | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y |
53+
| netcoreapp2.1 | Y | Y | Y | Y | Y | N | Y | N | Y | N |
54+
| netcoreapp2.0 | Y | N | N | N | N | N | Y | N | Y | N |
55+
| netstandard2.1 | Y | Y | N | Y | Y | N | Y | N | Y | N |
56+
| netstandard2.0 | N | N | N | N | N | N | Y | N | N | N |
57+
| netstandard1.3 | N | N | N | N | N | N | N | N | N | N |
58+
| net472, net48 | N | N | Y | N | N | N | Y | N | N | N |
59+
+===================+=======+==========+=====================+=============+=================+====================+==============+=========|============|===============|
60+
-->
61+
<Choose>
62+
<When Condition="'$(TargetFramework)' == 'net472' OR '$(TargetFramework)' == 'net48'">
63+
<PropertyGroup>
64+
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
65+
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
66+
</PropertyGroup>
67+
</When>
68+
<When Condition="'$(TargetFramework)' == 'netstandard2.0'">
69+
<PropertyGroup>
70+
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
71+
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
72+
</PropertyGroup>
73+
</When>
74+
<When Condition="'$(TargetFramework)' == 'netstandard2.1'">
75+
<PropertyGroup>
76+
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
77+
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
78+
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
79+
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
80+
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
81+
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
82+
</PropertyGroup>
83+
</When>
84+
<When Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
85+
<PropertyGroup>
86+
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
87+
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
88+
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
89+
</PropertyGroup>
90+
</When>
91+
<When Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
92+
<PropertyGroup>
93+
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
94+
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
95+
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
96+
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
97+
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
98+
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
99+
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
100+
</PropertyGroup>
101+
</When>
102+
<When Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','netcoreapp3.1'))">
103+
<!--NETCORE 3.1. NET5.0, and future versions will fallback to this as the closest target.-->
104+
<PropertyGroup>
105+
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
106+
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
107+
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
108+
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
109+
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
110+
<DefineConstants>$(DefineConstants);SUPPORTS_RUNTIME_INTRINSICS</DefineConstants>
111+
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
112+
<DefineConstants>$(DefineConstants);SUPPORTS_HOTPATH</DefineConstants>
113+
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
114+
<DefineConstants>$(DefineConstants);SUPPORTS_BITOPERATIONS</DefineConstants>
115+
</PropertyGroup>
116+
</When>
117+
</Choose>
56118

57119
</Project>

Diff for: src/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33

44
<PropertyGroup>
5-
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.6</TargetFrameworks>
5+
<TargetFrameworks>net452;netcoreapp2.1;netcoreapp3.1;netstandard1.6;netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
66
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props</MSBuildAllProjects>
77
<SynercodingProjectCategory>src</SynercodingProjectCategory>
88
</PropertyGroup>
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Synercoding.Primitives.Extensions
2+
{
3+
/// <summary>
4+
/// Extensions methods for <see cref="Point"/>
5+
/// </summary>
6+
public static class PointExtensions
7+
{
8+
/// <summary>
9+
/// Get the raw values representing this Point in a provided unit
10+
/// </summary>
11+
/// <param name="point">The point to get in raw format</param>
12+
/// <param name="unit">The unit to get the result in.</param>
13+
/// <returns>A tuple representing the raw values.</returns>
14+
public static (double X, double Y) AsRaw(this Point point, Unit unit)
15+
=> (point.X.AsRaw(unit), point.Y.AsRaw(unit));
16+
}
17+
}

Diff for: src/Synercoding.Primitives/Extensions/SizeExtensions.cs

+9
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,14 @@ public static Rectangle AsRectangle(this Size size)
4242
/// <returns>A new size with width and height switched</returns>
4343
public static Size Rotate(this Size size)
4444
=> new Size(size.Height, size.Width);
45+
46+
/// <summary>
47+
/// Get the raw values representing this Size in a provided unit
48+
/// </summary>
49+
/// <param name="size">The size to get in raw format</param>
50+
/// <param name="unit">The unit to get the result in.</param>
51+
/// <returns>A tuple representing the raw values.</returns>
52+
public static (double Width, double Height) AsRaw(this Size size, Unit unit)
53+
=> (size.Width.AsRaw(unit), size.Height.AsRaw(unit));
4554
}
4655
}

Diff for: src/Synercoding.Primitives/PackageDetails.props

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
<PackageTags>Primitives Unit Graphics</PackageTags>
1010
<Product>Synercoding.Primitives</Product>
1111
<Title>Synercoding.Primitives</Title>
12-
<Description>Primitives with types attached (think mm, cm, in, px) that can be used for 2D graphics.</Description>
12+
<Description>Primitives with units attached (think mm, cm, in, px) that can be used for 2D graphics.</Description>
1313
<PackageReleaseNotes>
14-
- Added extension method for Value .AsRaw(Unit)
15-
- Added Rotated property to size
14+
- Added support for net452 &amp; net5.0.
15+
- Added a ValueCreator class, supposed to be used as a static using.
16+
- Added AsRaw extensions for Point &amp; Size
1617
</PackageReleaseNotes>
1718
</PropertyGroup>
1819

Diff for: src/Synercoding.Primitives/Synercoding.Primitives.csproj

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
<PropertyGroup>
44
<Nullable>enable</Nullable>
5-
<LangVersion>8.0</LangVersion>
65
</PropertyGroup>
76

87
<Import Project="$(MSBuildThisFileDirectory)\PackageDetails.props" />
98

10-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netstandard1.6'">
9+
<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netstandard1.6'">
1110
<PackageReference Include="System.Memory " Version="4.5.4" />
1211
</ItemGroup>
1312

14-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6'">
13+
<ItemGroup Condition="'$(TargetFramework)' == 'net452' Or '$(TargetFramework)' == 'netstandard1.6'">
1514
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
1615
</ItemGroup>
1716

Diff for: src/Synercoding.Primitives/System/HashCode.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
4646

4747
[assembly: TypeForwardedTo(typeof(System.HashCode))]
4848
#else
49-
using System.Buffers.Binary;
5049
using System.Collections.Generic;
5150
using System.ComponentModel;
52-
using System.Diagnostics.CodeAnalysis;
5351
using System.Runtime.CompilerServices;
5452
using System.Security.Cryptography;
5553

@@ -82,7 +80,7 @@ private static uint GenerateGlobalSeed()
8280
rng.GetBytes(data);
8381
}
8482

85-
return BinaryPrimitives.ReadUInt32LittleEndian(data);
83+
return BitConverter.ToUInt32(data, 0);
8684
}
8785

8886
public static int Combine<T1>(T1 value1)

Diff for: src/Synercoding.Primitives/UnitDesignation.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Synercoding.Primitives
33
/// <summary>
44
/// Different designations for units
55
/// </summary>
6-
public enum UnitDesignation
6+
public enum UnitDesignation : byte
77
{
88
/// <summary>
99
/// Points, 72 per inch

Diff for: src/Synercoding.Primitives/ValueCreator.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace Synercoding.Primitives
2+
{
3+
/// <summary>
4+
/// Class that can be used as a static using to have quick &amp; easy access to values
5+
/// </summary>
6+
/// <example>
7+
/// using static Synercoding.Primitives.ValueCreator;
8+
/// </example>
9+
public static class ValueCreator
10+
{
11+
/// <summary>
12+
/// Create a new <see cref="Value"/> with <see cref="Unit"/> <see cref="Unit.Millimeters"/>
13+
/// </summary>
14+
/// <param name="mm">The amount of mm</param>
15+
/// <returns>A new <see cref="Value"/> object.</returns>
16+
public static Value Mm(double mm) => new Value(mm, Unit.Millimeters);
17+
/// <summary>
18+
/// Create a new <see cref="Value"/> with <see cref="Unit"/> <see cref="Unit.Centimeters"/>
19+
/// </summary>
20+
/// <param name="cm">The amount of cm</param>
21+
/// <returns>A new <see cref="Value"/> object.</returns>
22+
public static Value Cm(double cm) => new Value(cm, Unit.Centimeters);
23+
/// <summary>
24+
/// Create a new <see cref="Value"/> with <see cref="Unit"/> <see cref="Unit.Inches"/>
25+
/// </summary>
26+
/// <param name="inch">The amount of inch</param>
27+
/// <returns>A new <see cref="Value"/> object.</returns>
28+
public static Value Inch(double inch) => new Value(inch, Unit.Inches);
29+
/// <summary>
30+
/// Create a new <see cref="Value"/> with <see cref="Unit"/> <see cref="Unit.Points"/>
31+
/// </summary>
32+
/// <param name="pts">The amount of pts</param>
33+
/// <returns>A new <see cref="Value"/> object.</returns>
34+
public static Value Pts(double pts) => new Value(pts, Unit.Points);
35+
}
36+
}

Diff for: tests/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" />
1515

1616
<PropertyGroup>
17-
<TargetFramework>netcoreapp3.1</TargetFramework>
17+
<TargetFramework>net5.0</TargetFramework>
1818
<IsPackable>false</IsPackable>
1919
</PropertyGroup>
2020

0 commit comments

Comments
 (0)