Skip to content

Commit

Permalink
Upgrading to dotnet 8
Browse files Browse the repository at this point in the history
  • Loading branch information
tpill90 committed May 3, 2024
1 parent 56ff88c commit 2f842fc
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 58 deletions.
13 changes: 11 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end_of_line = lf
indent_style = space
indent_size = 4

# ----- Resharper Rules -----
# ----- Resharper Rules -----
# https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_CSharpIndentStylePageSchema.html#resharper_csharp_align_linq_query
align_linq_query = true
align_multiline_calls_chain = true
Expand Down Expand Up @@ -46,12 +46,21 @@ dotnet_diagnostic.CA1815.severity = none
# CA1822: Member does not access instance data and can be marked as static
dotnet_diagnostic.CA1822.severity = none
dotnet_diagnostic.CA1835.severity = none

# CA1854: Prefer the IDictionary.TryGetValue(TKey, out TValue) method
# - I'm not worried about performance in this application where ContainsKey() is being used, and I like the current syntax as far as readability
dotnet_diagnostic.CA1854.severity = none

# CA1860: Avoid using 'Enumerable.Any()' extension method, both for clarity and performance
# - I don't agree with this analyzer, using Any() is far more readable than comparing Count == 0, and has been a pattern in dotnet for more than a decade
dotnet_diagnostic.CA1860.severity = none

# CA2007: Consider calling ConfigureAwait on the awaited task
dotnet_diagnostic.CA2007.severity = none
# CA2201: Do not raise reserved exception types
dotnet_diagnostic.CA2201.severity = none

# CS1998: Async method lacks 'await' operators and will run synchronously
# CS1998: Async method lacks 'await' operators and will run synchronously
dotnet_diagnostic.cs1998.severity = error
# CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
dotnet_diagnostic.cs4014.severity = error
Expand Down
24 changes: 10 additions & 14 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# The duplicate releases happen because of a race condition, where each parallel publish job thinks the release has not yet been created.
create-placeholder-release:
runs-on: ubuntu-latest
container: mcr.microsoft.com/dotnet/sdk:6.0
container: mcr.microsoft.com/dotnet/sdk:8.0
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -27,20 +27,20 @@ jobs:
- name: Set Version
id: vars
run: |
version=$(grep -Po '(?<=<VersionPrefix>)(.*?)(?=</VersionPrefix>)' $PROJECT_NAME/$PROJECT_NAME.csproj);
version=$(grep -Po '(?<=<VersionPrefix>)(.*?)(?=</VersionPrefix>)' $PROJECT_NAME/$PROJECT_NAME.csproj);
echo "version=$version" >> $GITHUB_OUTPUT;
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
name: "v${{ steps.vars.outputs.version }}"
files: "**/*.zip"
files: "**/*.zip"
generate_release_notes: true

dotnet-publish:
runs-on: ubuntu-latest
container: mcr.microsoft.com/dotnet/sdk:6.0
container: mcr.microsoft.com/dotnet/sdk:8.0
needs: create-placeholder-release
strategy:
matrix:
Expand All @@ -54,23 +54,19 @@ jobs:
- name: Set Version
id: vars
run: |
version=$(grep -Po '(?<=<VersionPrefix>)(.*?)(?=</VersionPrefix>)' $PROJECT_NAME/$PROJECT_NAME.csproj);
version=$(grep -Po '(?<=<VersionPrefix>)(.*?)(?=</VersionPrefix>)' $PROJECT_NAME/$PROJECT_NAME.csproj);
echo "version=$version" >> $GITHUB_OUTPUT;
- run: apt-get update
- run: apt-get install zip -y
- name: Publish
- name: Publish
run: >
version=${{ steps.vars.outputs.version }}
dotnet publish $PROJECT_NAME/$PROJECT_NAME.csproj \
--nologo \
-o "publish/$PROJECT_NAME-$version-${{ matrix.runtime }}" \
-c Release \
--runtime "${{ matrix.runtime }}" \
--self-contained true \
/p:PublishSingleFile=true \
/p:PublishReadyToRun=true \
/p:PublishTrimmed=true;
--runtime "${{ matrix.runtime }}";
cd publish;
Expand All @@ -81,7 +77,7 @@ jobs:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: EpicPrefill-${{ steps.vars.outputs.version }}-${{ matrix.runtime }}
name: EpicPrefill-${{ steps.vars.outputs.version }}-${{ matrix.runtime }}
path: publish/
if-no-files-found: error
- name: Create Release
Expand All @@ -90,7 +86,7 @@ jobs:
with:
draft: true
name: "v${{ steps.vars.outputs.version }}"
files: "**/*.zip"
files: "**/*.zip"
generate_release_notes: true
docker-publish-x64:
runs-on: ubuntu-latest
Expand All @@ -101,7 +97,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Publish
run: >
dotnet publish $PROJECT_NAME/$PROJECT_NAME.csproj \
Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion EpicPrefill.Test/EpicPrefill.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
12 changes: 6 additions & 6 deletions EpicPrefill.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solutio
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EpicPrefill", "EpicPrefill\EpicPrefill.csproj", "{C9891AEF-F9A1-4D6C-9F48-AAB0B054EE81}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LancachePrefill.Common", "LancachePrefill.Common\LancachePrefill.Common.csproj", "{D983EC87-5052-4E88-8891-23EE47A5FF9A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{964C7C38-DF8F-4D47-AFD0-30B670EFA4AB}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml
Expand All @@ -25,16 +23,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Benchmarks\Be
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{D40480CD-E51C-48F5-B1C5-938420D33C3A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LancachePrefill.Common", "LancachePrefill.Common\dotnet\LancachePrefill.Common.csproj", "{DD478B94-C184-449D-86F8-E118690720A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D983EC87-5052-4E88-8891-23EE47A5FF9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D983EC87-5052-4E88-8891-23EE47A5FF9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D983EC87-5052-4E88-8891-23EE47A5FF9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D983EC87-5052-4E88-8891-23EE47A5FF9A}.Release|Any CPU.Build.0 = Release|Any CPU
{C9891AEF-F9A1-4D6C-9F48-AAB0B054EE81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9891AEF-F9A1-4D6C-9F48-AAB0B054EE81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9891AEF-F9A1-4D6C-9F48-AAB0B054EE81}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -47,6 +43,10 @@ Global
{3467CD6C-B4F2-4EE5-9872-407C2985C457}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3467CD6C-B4F2-4EE5-9872-407C2985C457}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3467CD6C-B4F2-4EE5-9872-407C2985C457}.Release|Any CPU.Build.0 = Release|Any CPU
{DD478B94-C184-449D-86F8-E118690720A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD478B94-C184-449D-86F8-E118690720A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD478B94-C184-449D-86F8-E118690720A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD478B94-C184-449D-86F8-E118690720A6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion EpicPrefill/EpicGamesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task DownloadMultipleAppsAsync(bool downloadAllOwnedGames, List<str
{
await DownloadSingleAppAsync(app);
}
catch (Exception e) when (e is LancacheNotFoundException || e is UserCancelledException)
catch (Exception e) when (e is LancacheNotFoundException)
{
// We'll want to bomb out the entire process for these exceptions, as they mean we can't prefill any apps at all
throw;
Expand Down
27 changes: 19 additions & 8 deletions EpicPrefill/EpicPrefill.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
<OutputType>Exe</OutputType>

Expand All @@ -9,26 +9,41 @@
<VersionPrefix>1.2.0</VersionPrefix>
<Authors>tpill90</Authors>

<AllowUnsafeBlocks>True</AllowUnsafeBlocks>

<!-- Code analysis settings -->
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Features>strict</Features>
<AnalysisLevel>latest</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<!-- Publish Settings -->
<PropertyGroup>
<PublishTrimmed>true</PublishTrimmed>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<!-- Reverts back to the default trim mode used by dotnet 6, otherwise CliFx breaks without reflection -->
<TrimMode>partial</TrimMode>

<PublishSingleFile>true</PublishSingleFile>

<!-- Required to be enabled in order to run this application on Ubuntu Docker images. -->
<InvariantGlobalization>true</InvariantGlobalization>

<!-- Removes the git commit hash being appended to the version number when publishing.. Ex: v2.3.0+5afde434cfe8472ba36138c4912e7aa08a7a22d0 -->
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<!-- Removes the full file system path from exception stack traces, only shows the file names now -->
<PathMap>$(MSBuildProjectDirectory)=$(MSBuildProjectName)</PathMap>
</PropertyGroup>

<!-- Includes Linux update script in publish package -->
<ItemGroup Condition="'$(RuntimeIdentifier)'=='linux-x64'">
<Content Include="..\scripts\**\update.sh">
Expand Down Expand Up @@ -84,10 +99,6 @@
<!-- Required definitions in order for Microsoft.CodeAnalysis.BannedApiAnalyzers to work -->
<AdditionalFiles Include="..\LancachePrefill.Common\BannedSymbols.txt" Link="Properties\BannedSymbols.txt" />

<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.9.60">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand All @@ -99,7 +110,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\LancachePrefill.Common\LancachePrefill.Common.csproj" />
<ProjectReference Include="..\LancachePrefill.Common\dotnet\LancachePrefill.Common.csproj" />
</ItemGroup>

</Project>
7 changes: 3 additions & 4 deletions EpicPrefill/Extensions/MiscExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public static byte[] Decompress(this byte[] bytes)
[SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 is required by Epic")]
public static byte[] ComputeSha1Hash(this byte[] input)
{
using var sha = SHA1.Create();
return sha.ComputeHash(input);
return SHA1.HashData(input);
}

public static string ToHexString(this byte[] input)
Expand Down Expand Up @@ -47,7 +46,7 @@ public static string ReadFstring(this BinaryReader br)

// Read bytes representing string
var bytes = br.ReadBytes(stringLength - 2);
// Reading utf-16 two byte null terminators
// Reading utf-16 two byte null terminators
br.ReadBytes(2);

return Encoding.Unicode.GetString(bytes);
Expand All @@ -58,7 +57,7 @@ public static string ReadFstring(this BinaryReader br)
{
// Read bytes representing string
var bytes = br.ReadBytes(stringLength - 1);
// Read null delimiter
// Read null delimiter
br.ReadBytes(1);

return Encoding.ASCII.GetString(bytes);
Expand Down
6 changes: 3 additions & 3 deletions EpicPrefill/Handlers/EpicGamesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<List<GameAsset>> GetOwnedAppsAsync()

// Read and deserialize
using var responseContent = await response.Content.ReadAsStreamAsync();
var ownedApps = JsonSerializer.Deserialize(responseContent, SerializationContext.Default.ListGameAsset);
var ownedApps = await JsonSerializer.DeserializeAsync(responseContent, SerializationContext.Default.ListGameAsset);

var appMetadata = await LoadAppMetadataAsync(ownedApps);
foreach (var app in ownedApps)
Expand Down Expand Up @@ -112,7 +112,7 @@ private async Task<AppMetadataResponse> GetSingleAppMetadataAsync(GameAsset appI
response.EnsureSuccessStatusCode();

using var responseStream = await response.Content.ReadAsStreamAsync();
var appMetadata = JsonSerializer.Deserialize(responseStream, SerializationContext.Default.DictionaryStringAppMetadataResponse);
var appMetadata = await JsonSerializer.DeserializeAsync(responseStream, SerializationContext.Default.DictionaryStringAppMetadataResponse);

return appMetadata.Values.First();
}
Expand All @@ -129,7 +129,7 @@ public async Task<List<ManifestUrl>> GetAllDownloadUrlsAsync(GameAsset appInfo)
response.EnsureSuccessStatusCode();

using var responseStream = await response.Content.ReadAsStreamAsync();
ManifestResponse deserialized = JsonSerializer.Deserialize(responseStream, SerializationContext.Default.ManifestResponse);
ManifestResponse deserialized = await JsonSerializer.DeserializeAsync(responseStream, SerializationContext.Default.ManifestResponse);

return deserialized.elements.First().manifests.ToList();
}
Expand Down
2 changes: 1 addition & 1 deletion EpicPrefill/Handlers/UserAccountManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async Task LoginAsync()
response.EnsureSuccessStatusCode();

using var responseStream = await response.Content.ReadAsStreamAsync();
OauthToken = JsonSerializer.Deserialize(responseStream, SerializationContext.Default.OauthToken);
OauthToken = await JsonSerializer.DeserializeAsync(responseStream, SerializationContext.Default.OauthToken);

Save();
}
Expand Down
13 changes: 3 additions & 10 deletions EpicPrefill/Models/Exceptions/EpicLoginException.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
namespace EpicPrefill.Models.Exceptions
{
public class EpicLoginException : Exception
public sealed class EpicLoginException : Exception
{
protected EpicLoginException(SerializationInfo info, StreamingContext context) : base(info, context)
public EpicLoginException(string message) : base(message)
{

}

public EpicLoginException()
{

}

public EpicLoginException(string message) : base(message)
{

}

public EpicLoginException(string message, Exception inner) : base(message, inner)
public EpicLoginException(string message, Exception innerException) : base(message, innerException)
{

}
}
}
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

0 comments on commit 2f842fc

Please sign in to comment.