Skip to content

Commit

Permalink
Merge pull request #336 from /issues/215-UpdateToDotnet8
Browse files Browse the repository at this point in the history
  • Loading branch information
tpill90 authored Nov 26, 2023
2 parents 1c166dd + e344e97 commit 196b45e
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 94 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,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 Down
11 changes: 4 additions & 7 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,7 +98,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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ lockfile
/docs/site
/docs/__pycache__
/docs/RenderAnsiToSvg/__pycache__
/SteamPrefill/app.log
2 changes: 1 addition & 1 deletion SteamPrefill.Test/SteamPrefill.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
8 changes: 1 addition & 7 deletions SteamPrefill/Extensions/MiscExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public static class MiscExtensions
{
//TODO rename to IsEmpty
public static bool Empty<T>(this IEnumerable<T> enumerable)
{
return !enumerable.Any();
Expand All @@ -20,13 +21,6 @@ public static void AddRange<T>(this HashSet<T> hashSet, List<T> values)
}
}

[SuppressMessage("Microsoft.Security", "CA5350", Justification = "SHA1 is required by Steam")]
public static byte[] ToSha1(this byte[] input)
{
using var sha = SHA1.Create();
return sha.ComputeHash(input);
}

[SuppressMessage("Security", "CA5394:Random is an insecure RNG", Justification = "Security doesn't matter here, just need to shuffle requests.")]
public static void Shuffle<T>(this IList<T> list)
{
Expand Down
2 changes: 1 addition & 1 deletion SteamPrefill/Handlers/AppInfoHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private async Task BulkLoadAppInfoAsync(List<uint> appIds)
/// <param name="appIdsToLoad">The list of App Ids to retrieve info for</param>
private async Task AppInfoRequestAsync(List<uint> appIdsToLoad)
{
if (!appIdsToLoad.Any())
if (appIdsToLoad.Empty())
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions SteamPrefill/Handlers/DownloadHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ await _ansiConsole.CreateSpectreProgress(downloadArgs.TransferSpeedUnit).StartAs
});

// Handling final failed requests
if (!failedRequests.Any())
if (failedRequests.IsEmpty)
{
return true;
}
Expand Down Expand Up @@ -103,7 +103,7 @@ public async Task<ConcurrentBag<QueuedRequest>> AttemptDownloadAsync(ProgressCon
catch (Exception e)
{
failedRequests.Add(request);
FileLogger.LogException($"Request /depot/{request.DepotId}/chunk/{request.ChunkId} failed", e);
FileLogger.LogExceptionNoStackTrace($"Request /depot/{request.DepotId}/chunk/{request.ChunkId} failed", e);
}
progressTask.Increment(request.CompressedLength);
});
Expand Down
2 changes: 1 addition & 1 deletion SteamPrefill/Models/AppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public DateTime? ReleaseDate
public List<string> OSList { get; }

// Some games simply don't have any OSList at all, so this means that they should always be considered as supported.
public bool SupportsWindows => !OSList.Any() || OSList.Contains("windows");
public bool SupportsWindows => OSList.Empty() || OSList.Contains("windows");

/// <summary>
/// Specifies the type of app, can be "config", "tool", "game". This seems to be up to the developer, and isn't 100% consistent.
Expand Down
7 changes: 1 addition & 6 deletions SteamPrefill/Models/Exceptions/BenchmarkException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
namespace SteamPrefill.Models.Exceptions
{
public class BenchmarkException : Exception
public sealed class BenchmarkException : Exception
{
protected BenchmarkException(SerializationInfo info, StreamingContext context) : base(info, context)
{

}

public BenchmarkException()
{

Expand Down
7 changes: 1 addition & 6 deletions SteamPrefill/Models/Exceptions/CdnExhaustionException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
namespace SteamPrefill.Models.Exceptions
{
public class CdnExhaustionException : Exception
public sealed class CdnExhaustionException : Exception
{
private CdnExhaustionException(SerializationInfo info, StreamingContext context) : base(info, context)
{

}

public CdnExhaustionException()
{

Expand Down
7 changes: 1 addition & 6 deletions SteamPrefill/Models/Exceptions/InfiniteLoopException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
namespace SteamPrefill.Models.Exceptions
{
public class InfiniteLoopException : Exception
public sealed class InfiniteLoopException : Exception
{
protected InfiniteLoopException(SerializationInfo info, StreamingContext context) : base(info, context)
{

}

public InfiniteLoopException()
{

Expand Down
7 changes: 1 addition & 6 deletions SteamPrefill/Models/Exceptions/ManifestException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
namespace SteamPrefill.Models.Exceptions
{
public class ManifestException : Exception
public sealed class ManifestException : Exception
{
protected ManifestException(SerializationInfo info, StreamingContext context) : base(info, context)
{

}

public ManifestException()
{

Expand Down
7 changes: 1 addition & 6 deletions SteamPrefill/Models/Exceptions/SteamConnectionException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
namespace SteamPrefill.Models.Exceptions
{
public class SteamConnectionException : Exception
public sealed class SteamConnectionException : Exception
{
protected SteamConnectionException(SerializationInfo info, StreamingContext context) : base(info, context)
{

}

public SteamConnectionException()
{

Expand Down
7 changes: 1 addition & 6 deletions SteamPrefill/Models/Exceptions/SteamLoginException.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
namespace SteamPrefill.Models.Exceptions
{
public class SteamLoginException : Exception
public sealed class SteamLoginException : Exception
{
protected SteamLoginException(SerializationInfo info, StreamingContext context) : base(info, context)
{

}

public SteamLoginException()
{

Expand Down
17 changes: 6 additions & 11 deletions SteamPrefill/SteamManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task DownloadMultipleAppsAsync(bool downloadAllOwnedGames, bool pre
{
await DownloadSingleAppAsync(app.AppId);
}
catch (Exception e) when (e is LancacheNotFoundException || e is UserCancelledException || e is InfiniteLoopException)
catch (Exception e) when (e is LancacheNotFoundException || e is InfiniteLoopException)
{
// 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 All @@ -131,7 +131,7 @@ private async Task DownloadSingleAppAsync(uint appId)

// Filter depots based on specified language/OS/cpu architecture/etc
var filteredDepots = await _depotHandler.FilterDepotsToDownloadAsync(_downloadArgs, appInfo.Depots);
if (!filteredDepots.Any())
if (filteredDepots.Empty())
{
//TODO add to summary output?
_ansiConsole.LogMarkupLine($"Starting {Cyan(appInfo)} {LightYellow("No depots to download. Current arguments filtered all depots")}");
Expand Down Expand Up @@ -164,12 +164,7 @@ await _ansiConsole.StatusSpinner().StartAsync("Fetching depot manifests...", asy
var totalBytes = ByteSize.FromBytes(chunkDownloadQueue.Sum(e => e.CompressedLength));
_prefillSummaryResult.TotalBytesTransferred += totalBytes;

//TODO make this look nicer
_ansiConsole.LogMarkup($"Downloading {Magenta(totalBytes.ToDecimalString())}");
#if DEBUG
_ansiConsole.Markup($" from {LightYellow(chunkDownloadQueue.Count)} chunks");
#endif
_ansiConsole.MarkupLine("");
_ansiConsole.LogMarkupVerbose($"Downloading {Magenta(totalBytes.ToDecimalString())} from {LightYellow(chunkDownloadQueue.Count)} chunks");

if (AppConfig.SkipDownloads)
{
Expand Down Expand Up @@ -238,7 +233,7 @@ private async Task PrintUnownedAppsAsync(List<uint> distinctAppIds)
_prefillSummaryResult.UnownedAppsSkipped = unownedApps.Length;


if (!unownedApps.Any())
if (unownedApps.Empty())
{
return;
}
Expand Down Expand Up @@ -324,7 +319,7 @@ await _ansiConsole.CreateSpectreProgress(TransferSpeedUnit.Bytes, displayTransfe
{
var filteredDepots = await _depotHandler.FilterDepotsToDownloadAsync(_downloadArgs, appInfo.Depots);
await _depotHandler.BuildLinkedDepotInfoAsync(filteredDepots);
if (!filteredDepots.Any())
if (filteredDepots.Empty())
{
_ansiConsole.LogMarkupLine($"{Cyan(appInfo)} - {LightYellow("No depots to download. Current arguments filtered all depots")}");
return;
Expand All @@ -335,7 +330,7 @@ await _ansiConsole.CreateSpectreProgress(TransferSpeedUnit.Bytes, displayTransfe
var appFileListing = new AppQueuedRequests(appInfo.Name, appInfo.AppId, allChunksForApp);
queuedApps.Add(appFileListing);
}
catch (Exception e) when (e is LancacheNotFoundException || e is UserCancelledException || e is InfiniteLoopException)
catch (Exception e) when (e is LancacheNotFoundException || e is InfiniteLoopException)
{
// Bomb out the whole process, since these are completely unrecoverable
throw;
Expand Down
10 changes: 8 additions & 2 deletions SteamPrefill/SteamPrefill.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 @@ -17,10 +17,16 @@
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<!-- Trim Settings -->
<!-- Publish Settings -->
<PropertyGroup>
<PublishTrimmed>true</PublishTrimmed>
<!-- 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>

<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<!-- Required to be enabled in order to run this application on Ubuntu Docker images. -->
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
Expand Down
14 changes: 2 additions & 12 deletions docs/mkdocs/dev-guides/Compiling-from-source.gr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@

## Απαιρέτητα πακετά για την εγκατάσταση

Χρειαζόμαστε μόνο το .NET 6 SDK για να κάνουμε compile αυτό το έργο. Αυτό μπορεί να γίνει με τις παρακάτω μεθόδους
Χρειαζόμαστε μόνο το .NET 8 SDK για να κάνουμε compile αυτό το έργο. Αυτό μπορεί να γίνει με τις παρακάτω μεθόδους

### Με το Chocolatey
```powershell
choco install dotnet-6.0-sdk
choco install dotnet-sdk --version=8.0.100
```

### Χειροκίνητα
Με το τελευταίο .NET 6.0 SDK που μπορούμε να βρούμε εδώ [.NET 6.0 SDK - Windows x64 Installer](https://download.visualstudio.microsoft.com/download/pr/deb4711b-7bbc-4afa-8884-9f2b964797f2/fb603c451b2a6e0a2cb5372d33ed68b9/dotnet-sdk-6.0.300-win-x64.exe)

## Διορθώνοντας το αρχικό config του Nuget

```powershell
# Πρέπει να σβηστεί, για να λύσουμε το θέμα με την λάθος προρύθμιση του Buget.
# Θα αυτόδημιουργηθεί με την πρώτη εκτέλεση.
Remove-Item "C:\Users\$Env:USERNAME\AppData\Roaming\NuGet\nuget.config"
```

## Κλωνοποίηση του repo και των submodules

Expand Down
9 changes: 2 additions & 7 deletions docs/mkdocs/dev-guides/Compiling-from-source.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# Compiling From Source

<!-- TODO go through each page and add ----- to sections to make it easier to read -->

## Installing Prerequisites

<!-- TODO add git here -->
Only the .NET 6 SDK is required to compile the project. The following instructions will be using Chocolatey as a package manager for Windows, which makes installing software much easier as it can be done by a single command. Chocolatey can be installed using the [Chocolatey install guide](https://chocolatey.org/install#individual) if it isn't already installed.
Only the .NET 8 SDK is required to compile the project. The following instructions will be using Chocolatey as a package manager for Windows, which makes installing software much easier as it can be done by a single command. Chocolatey can be installed using the [Chocolatey install guide](https://chocolatey.org/install#individual) if it isn't already installed.

### dotnet SDK

```powershell
choco install dotnet-6.0-sdk
# Needs to be removed in order to resolve issue with Nuget's being misconfigured by default after install.
Remove-Item "C:\Users\$Env:USERNAME\AppData\Roaming\NuGet\nuget.config"
choco install dotnet-sdk --version=8.0.100
```

### Git
Expand Down
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

0 comments on commit 196b45e

Please sign in to comment.