Skip to content

Commit

Permalink
Build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tpill90 committed Dec 18, 2023
1 parent 705b422 commit cf24295
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 22 deletions.
18 changes: 9 additions & 9 deletions BattleNetPrefill/BattleNetPrefill.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<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,18 +19,22 @@
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
</PropertyGroup>

<!-- Publish 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>

<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<!-- 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 @@ -106,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

0 comments on commit cf24295

Please sign in to comment.