Skip to content

Commit e066b22

Browse files
authored
Merge pull request #26 from mrdav30/develop
feat: update (#25)
2 parents 38024ba + 448d4b4 commit e066b22

File tree

3 files changed

+103
-32
lines changed

3 files changed

+103
-32
lines changed

.github/workflows/dotnet.yml

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ on:
1616
- 'main'
1717

1818
jobs:
19-
build:
20-
if: (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/')))
21-
# Use an Ubuntu-based container to build the project
19+
build-and-test-linux:
20+
if: |
21+
(github.event_name != 'pull_request' && !github.event.pull_request.head.repo.fork)
22+
|| (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork
23+
|| startsWith(github.head_ref, 'dependabot/')))
2224
runs-on: ubuntu-latest
2325

24-
container:
25-
image: unityci/editor:ubuntu-2022.3.20f1-windows-mono-3.1.0
26-
2726
steps:
2827
- name: Checkout repository
2928
uses: actions/checkout@v4
@@ -35,7 +34,12 @@ jobs:
3534
uses: actions/setup-dotnet@v4
3635
with:
3736
dotnet-version: 8.0.x
38-
37+
38+
- name: Install Mono (required for .NET Framework tests on Linux)
39+
run: |
40+
sudo apt update
41+
sudo apt install -y mono-complete
42+
3943
- name: Install GitVersion
4044
uses: gittools/actions/gitversion/setup@v3.1.1
4145
with:
@@ -50,42 +54,81 @@ jobs:
5054
${{ runner.os }}-nuget-
5155
5256
- name: Determine Version
57+
id: version_step
5358
run: |
5459
chown -R $(whoami) $(pwd)
55-
dotnet-gitversion /output json
60+
dotnet-gitversion /output json > version.json
61+
echo "FULL_SEM_VER=$(grep -oP '"FullSemVer":\s*"\K[^"]+' version.json)" >> $GITHUB_ENV
62+
echo "ASSEMBLY_VERSION=$(grep -oP '"AssemblySemFileVer":\s*"\K[^"]+' version.json)" >> $GITHUB_ENV
5663
5764
- name: Restore dependencies
5865
run: dotnet restore
5966

6067
- name: Build Solution
61-
env:
62-
UnityManagedPath: \opt\unity\Editor\Data\Managed
6368
run: |
64-
echo "Version:${{ env.GitVersion_FullSemVer }}\nAssembley Version:${{ env.GitVersion_AssemblySemFileVer }}"
65-
dotnet build --configuration Release --no-restore
69+
echo "Version: ${{ env.FULL_SEM_VER }}"
70+
echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
71+
dotnet build --configuration Debug --no-restore
6672
67-
- name: Upload Test Artifacts
68-
uses: actions/upload-artifact@v4
69-
with:
70-
name: BuildOutputTest
71-
path: ./tests/FixedMathSharp.Tests/bin/Release
73+
- name: Test .NET48
74+
run: |
75+
mono ~/.nuget/packages/xunit.runner.console/2.9.3/tools/net48/xunit.console.exe ${{github.workspace}}/tests/FixedMathSharp.Tests/bin/Debug/net48/FixedMathSharp.Tests.dll
76+
77+
- name: Test .NET8
78+
run: |
79+
dotnet test -f net8 --verbosity normal
7280
73-
test:
74-
# Use a Windows runner to execute the .NET Framework tests
81+
build-and-test-windows:
82+
if: |
83+
(github.event_name != 'pull_request' && !github.event.pull_request.head.repo.fork)
84+
|| (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork
85+
|| startsWith(github.head_ref, 'dependabot/')))
7586
runs-on: windows-latest
76-
needs: build
77-
7887
steps:
7988
- name: Checkout repository
8089
uses: actions/checkout@v4
81-
82-
- name: Download Test Artifacts
83-
uses: actions/download-artifact@v4
8490
with:
85-
name: BuildOutputTest
86-
path: ./tests/FixedMathSharp.Tests/bin/Release
87-
88-
- name: Test
91+
fetch-depth: 0
92+
persist-credentials: false
93+
94+
- name: Setup .NET
95+
uses: actions/setup-dotnet@v4
96+
with:
97+
dotnet-version: 8.0.x
98+
99+
- name: Install GitVersion
100+
uses: gittools/actions/gitversion/setup@v3.1.1
101+
with:
102+
versionSpec: 6.0.x
103+
104+
- name: Cache NuGet packages
105+
uses: actions/cache@v3
106+
with:
107+
path: ~/.nuget/packages
108+
key: '${{ runner.os }}-nuget-${{ hashFiles(''**/*.csproj'', ''**/*.sln'') }}'
109+
restore-keys: |
110+
${{ runner.os }}-nuget-
111+
112+
- name: Determine Version
113+
id: version_step
114+
shell: pwsh
115+
run: |
116+
chown -R $env:USERNAME $(Get-Location)
117+
dotnet-gitversion /output json | Out-File -FilePath version.json
118+
$json = Get-Content version.json | ConvertFrom-Json
119+
echo "FULL_SEM_VER=$($json.FullSemVer)" | Out-File -FilePath $env:GITHUB_ENV -Append
120+
echo "ASSEMBLY_VERSION=$($json.AssemblySemFileVer)" | Out-File -FilePath $env:GITHUB_ENV -Append
121+
122+
- name: Restore dependencies
123+
run: dotnet restore
124+
125+
- name: Build Solution
126+
run: |
127+
echo "Version: ${{ env.FULL_SEM_VER }}"
128+
echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
129+
dotnet build --configuration Debug --no-restore
130+
131+
- name: Test .NET48 & .NET8
89132
run: |
90133
dotnet --info
91-
dotnet test ${{ github.workspace }}\tests\FixedMathSharp.Tests\bin\Release\net48\FixedMathSharp.Tests.dll --verbosity normal
134+
dotnet test --verbosity normal

src/FixedMathSharp/Fixed64.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,26 @@ public static double ToDouble(long f1)
665665
return f1 * FixedMath.SCALE_FACTOR_D;
666666
}
667667

668+
/// <summary>
669+
/// Converts a Fixed64s RawValue (Int64) into a float
670+
/// </summary>
671+
/// <param name="f1"></param>
672+
/// <returns></returns>
673+
public static float ToFloat(long f1)
674+
{
675+
return f1 * FixedMath.SCALE_FACTOR_F;
676+
}
677+
678+
/// <summary>
679+
/// Converts a Fixed64s RawValue (Int64) into a decimal
680+
/// </summary>
681+
/// <param name="f1"></param>
682+
/// <returns></returns>
683+
public static decimal ToDecimal(long f1)
684+
{
685+
return f1 * FixedMath.SCALE_FACTOR_M;
686+
}
687+
668688
#endregion
669689

670690
#region Equality, HashCode, Comparable Overrides

tests/FixedMathSharp.Tests/FixedMathSharp.Tests.csproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,25 @@
66
<Nullable>enable</Nullable>
77
<IsPackable>false</IsPackable>
88
<IsTestProject>true</IsTestProject>
9-
<Configurations>Debug;Release;DebugUnity;ReleaseUnity</Configurations>
9+
<Configurations>Debug;Release</Configurations>
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<ProjectReference Include="..\..\src\FixedMathSharp\FixedMathSharp.csproj">
1313
<Private>True</Private>
1414
<IncludeAssets>compile; build</IncludeAssets>
1515
<PrivateAssets>all</PrivateAssets>
1616
</ProjectReference>
17+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net48" Version="1.0.3">
18+
<PrivateAssets>all</PrivateAssets>
19+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
20+
</PackageReference>
1721
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
18-
<PackageReference Include="xunit" Version="2.4.2" />
19-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
22+
<PackageReference Include="xunit" Version="2.9.3" />
23+
<PackageReference Include="xunit.runner.console" Version="2.9.3">
24+
<PrivateAssets>all</PrivateAssets>
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
</PackageReference>
27+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
2028
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2129
<PrivateAssets>all</PrivateAssets>
2230
</PackageReference>

0 commit comments

Comments
 (0)