Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed code analysis issues #500

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release
- Dependencies - Updated Nullable.Extended.Analyzer to 1.15.6169
- Dependencies - Updated FunFair.Test.Common to 6.1.27.296
- Dependencies - Updated Meziantou.Analyzer to 2.0.132
- SDK - Updated DotNet SDK to 8.0.101
### Removed
### Removed
- Nothing
### Deployment Changes

<!--
Expand Down
24 changes: 5 additions & 19 deletions src/Experiments/Implementations/HashedContentOptimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ private static void EnsureFolderExists(string destinationPath)
}
}

private void ChangeReferencesInNonRenamableTextFiles(IReadOnlyList<StrippedFile> fixedNameTextFiles,
Dictionary<string, string> textFiles,
Dictionary<string, string> fileHashes)
private void ChangeReferencesInNonRenamableTextFiles(IReadOnlyList<StrippedFile> fixedNameTextFiles, Dictionary<string, string> textFiles, Dictionary<string, string> fileHashes)
{
this._logger.LogInformation("Changing references in non-renamable text files");

Expand Down Expand Up @@ -289,7 +287,7 @@ private void ReplaceTextFilesInRenamableTextFiles(IReadOnlyList<StrippedFile> re

foreach (StrippedFile referencedFile in renamableTextFiles)
{
if (referencedFile.Path == file.Path)
if (StringComparer.Ordinal.Equals(x: referencedFile.Path, y: file.Path))
{
continue;
}
Expand Down Expand Up @@ -349,11 +347,7 @@ private void AddRemainingRenamableFiles(IReadOnlyList<StrippedFile> renamableTex
}
}

private void MakeReplacement(IReadOnlyList<StrippedFile> renamableTextFiles,
Dictionary<string, string> fileHashes,
Dictionary<string, string> textFiles,
StrippedFile file,
string newHashedPath)
private void MakeReplacement(IReadOnlyList<StrippedFile> renamableTextFiles, Dictionary<string, string> fileHashes, Dictionary<string, string> textFiles, StrippedFile file, string newHashedPath)
{
foreach (StrippedFile referencing in renamableTextFiles)
{
Expand All @@ -366,11 +360,7 @@ private void MakeReplacement(IReadOnlyList<StrippedFile> renamableTextFiles,
string newRelative = PathHelpers.GetRelativePath(documentFullPath: referencing.Path, referencedFileFullPath: newHashedPath);
string referencingContent = textFiles[referencing.Path];

bool changed = this.ChangeContent(relative: relativeInReferencing,
newRelative: newRelative,
hashedFilePath: file.Path,
newHashedPath: newHashedPath,
content: ref referencingContent);
bool changed = this.ChangeContent(relative: relativeInReferencing, newRelative: newRelative, hashedFilePath: file.Path, newHashedPath: newHashedPath, content: ref referencingContent);

if (changed)
{
Expand Down Expand Up @@ -426,11 +416,7 @@ private void ReplaceBinaryFilesInTextFiles(IReadOnlyList<StrippedFile> renamable
string relative = PathHelpers.GetRelativePath(documentFullPath: file.Path, referencedFileFullPath: binaryFile.Path);
string newRelative = string.Concat(relative.AsSpan(start: 0, relative.Length - binaryFile.FileName.Length), str1: hashedBinary);

hasChange |= this.ChangeContent(relative: relative,
newRelative: newRelative,
hashedFilePath: binaryFile.Path,
newHashedPath: hashedBinary,
content: ref content);
hasChange |= this.ChangeContent(relative: relative, newRelative: newRelative, hashedFilePath: binaryFile.Path, newHashedPath: hashedBinary, content: ref content);
}

if (hasChange)
Expand Down
Loading