Skip to content

Commit

Permalink
Merge pull request #108 from /issues/59-UpgradeDotnet8
Browse files Browse the repository at this point in the history
  • Loading branch information
tpill90 authored Dec 18, 2023
2 parents cb10827 + 3f9b519 commit 176ceb2
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 45 deletions.
22 changes: 21 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ root = true
[*]
end_of_line = lf

[*.js]
indent_style = tab
tab_size = 4
curly_bracket_next_line = true

[*.py]
indent_style = tab
tab_size = 4

# .NET formatting rules. See https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/formatting-rules
# Resharper Rules. See https://www.jetbrains.com/help/resharper/EditorConfig_Index.html
[*.cs]
Expand Down Expand Up @@ -41,13 +50,23 @@ dotnet_diagnostic.CA1056.severity = none
dotnet_diagnostic.CA1062.severity = none
# CA1305: The behavior of 'int.Parse(string)' could vary based on the current user's locale settings.
dotnet_diagnostic.CA1305.severity = none
# CA1307: Specify StringComparison for clarity
dotnet_diagnostic.CA1307.severity = none
dotnet_diagnostic.CA1310.severity = none
# CA1815: Override equals and operator equals on value types
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
Expand All @@ -65,4 +84,5 @@ csharp_style_implicit_object_creation_when_type_is_apparent = false
dotnet_diagnostic.rs0030.severity = error

# The method does not need to use async/await - Introduces annoying 'return' statements for async methods, that hurt code readability.
dotnet_diagnostic.AsyncFixer01.severity = none
dotnet_diagnostic.AsyncFixer01.severity = none

16 changes: 5 additions & 11 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 @@ -40,7 +40,7 @@ jobs:

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 @@ -67,10 +67,7 @@ jobs:
-o "publish/$PROJECT_NAME-$version-${{ matrix.runtime }}" \
-c Release \
--runtime "${{ matrix.runtime }}" \
--self-contained true \
/p:PublishSingleFile=true \
/p:PublishReadyToRun=true \
/p:PublishTrimmed=true;
--self-contained true;
cd publish;
Expand Down Expand Up @@ -101,18 +98,15 @@ 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 \
--nologo \
-o publish \
-c Release \
--runtime "linux-x64" \
--self-contained true \
/p:PublishSingleFile=true \
/p:PublishReadyToRun=true \
/p:PublishTrimmed=true
--self-contained true;
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
Expand Down
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>
<OutputType>Library</OutputType>

<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion BattleNetPrefill.Test/BattleNetPrefill.Test.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>
<OutputType>Library</OutputType>

<IsPackable>false</IsPackable>
Expand Down
23 changes: 15 additions & 8 deletions BattleNetPrefill/BattleNetPrefill.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<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>

<AllowUnsafeBlocks>True</AllowUnsafeBlocks>

<AssemblyName>BattleNetPrefill</AssemblyName>
<RootNamespace>BattleNetPrefill</RootNamespace>
<VersionPrefix>1.6.1</VersionPrefix>
<Authors>tpill90</Authors>

<AllowUnsafeBlocks>True</AllowUnsafeBlocks>

<!-- Code analysis settings -->
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Features>strict</Features>
Expand All @@ -19,11 +19,22 @@
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<!-- Trim Settings -->
<!-- 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>

<PublishReadyToRun>true</PublishReadyToRun>
<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>

<!--TODO is this needed?-->
Expand Down Expand Up @@ -99,10 +110,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 Down
9 changes: 4 additions & 5 deletions BattleNetPrefill/Handlers/ConfigFileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public async Task<CDNConfigFile> GetCdnConfigAsync(VersionsEntry targetVersion)
var cdnConfig = new CDNConfigFile();

var content = Encoding.UTF8.GetString(await _cdnRequestManager.GetRequestAsBytesAsync(RootFolder.config, targetVersion.cdnConfig));
var cdnConfigLines = content.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
var cdnConfigLines = content.Split("\n", StringSplitOptions.RemoveEmptyEntries);

for (var i = 0; i < cdnConfigLines.Length; i++)
{
if (cdnConfigLines[i].StartsWith("#") || cdnConfigLines[i].Length == 0) { continue; }
var cols = cdnConfigLines[i].Split(new string[] { " = " }, StringSplitOptions.RemoveEmptyEntries);
if (cdnConfigLines[i].StartsWith('#') || cdnConfigLines[i].Length == 0) { continue; }
var cols = cdnConfigLines[i].Split(" = ", StringSplitOptions.RemoveEmptyEntries);
switch (cols[0])
{
case "archives":
Expand Down Expand Up @@ -91,8 +91,7 @@ public async Task<VersionsEntry> GetLatestVersionEntryAsync(TactProduct tactProd
var versions = new VersionsFile();
string content = await _cdnRequestManager.MakePatchRequestAsync(tactProduct, PatchRequest.versions);

var lines = content.Replace("\0", "")
.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
var lines = content.Replace("\0", "").Split("\n", StringSplitOptions.RemoveEmptyEntries);

var lineList = new List<string>();

Expand Down
6 changes: 3 additions & 3 deletions BattleNetPrefill/Parsers/BuildConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public static async Task<BuildConfigFile> GetBuildConfigAsync(VersionsEntry vers
throw new Exception("Error reading build config!");
}

var lines = content.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
var lines = content.Split("\n", StringSplitOptions.RemoveEmptyEntries);
for (var i = 0; i < lines.Length; i++)
{
if (lines[i].StartsWith("#") || lines[i].Length == 0)
if (lines[i].StartsWith('#') || lines[i].Length == 0)
{
continue;
}

var cols = lines[i].Split(new string[] { " = " }, StringSplitOptions.RemoveEmptyEntries);
var cols = lines[i].Split(" = ", StringSplitOptions.RemoveEmptyEntries);
switch (cols[0])
{
case "root":
Expand Down
2 changes: 2 additions & 0 deletions BattleNetPrefill/Parsers/CdnsFileParser.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
namespace BattleNetPrefill.Parsers
{
[SuppressMessage("Performance", "CA1861:Avoid constant arrays as arguments", Justification = "Performance isn't an issue here, and implementing this warning's suggestion will impact readability negatively.")]
public static class CdnsFileParser
{

public static async Task<CdnsFile> ParseCdnsFileAsync(CdnRequestManager cdnRequestManager, TactProduct targetProduct)
{
string content = await cdnRequestManager.MakePatchRequestAsync(targetProduct, PatchRequest.cdns);
Expand Down
5 changes: 1 addition & 4 deletions BattleNetPrefill/Parsers/IndexParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ public static async Task<Dictionary<MD5Hash, IndexEntry>> ParseIndexAsync(CdnReq
continue;
}

if (!indexDict.ContainsKey(headerHash))
{
indexDict.Add(headerHash, indexEntry);
}
indexDict.TryAdd(headerHash, indexEntry);
}

bin.ReadBytes(blockPadding);
Expand Down
1 change: 1 addition & 0 deletions BattleNetPrefill/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
global using System.Collections.Concurrent;
global using System.Collections.Generic;
global using System.Diagnostics;
global using System.Diagnostics.CodeAnalysis;
global using System.IO;
global using System.IO.Compression;
global using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion BattleNetPrefill/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Prefill Blizzard - No Cache - No Download": {
"commandName": "Project",
"commandLineArgs": "prefill -p s1 --force"
"commandLineArgs": "prefill --blizzard --no-download --force"
},
"Prefill Games used for testing": {
"commandName": "Project",
Expand Down
2 changes: 1 addition & 1 deletion BattleNetPrefill/TactProductHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task<ComparisonResult> ProcessProductAsync(TactProduct product)
_ansiConsole.Write("\n");
return null;
}

await _ansiConsole.StatusSpinner().StartAsync("Start", async ctx =>
{
// Getting other configuration files for this version, that detail where we can download the required files from.
Expand Down
2 changes: 1 addition & 1 deletion LogFileGenerator/LogFileGenerator.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 LogFileGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class Program
TactProduct.Overwatch2, TactProduct.WorldOfWarcraft, TactProduct.WowClassic
};

private static List<TactProduct> ProductsToCheck = new List<TactProduct>
private static List<TactProduct> ProductsToCheck = new List<TactProduct>
{
TactProduct.Starcraft1, TactProduct.Starcraft2, TactProduct.Overwatch2, TactProduct.WorldOfWarcraft, TactProduct.WowClassic
};
Expand Down
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

0 comments on commit 176ceb2

Please sign in to comment.