Enforce NuGet warnings as errors; refactor field access

Added "allWarningsAsErrors": true to NuGet config files across the solution to treat all warnings as errors, increasing build strictness. Updated project cache hashes and assembly info files to reflect these changes. Refactored C# code to use explicit `this.` for field and property assignments, improving clarity. Note: some method signatures were incorrectly changed to use `this.` as a prefix, which is invalid C# syntax and must be corrected before compiling. Binary files updated due to build changes.
This commit is contained in:
2026-02-21 11:07:54 -05:00
parent 2b3a0c9746
commit 477045704e
141 changed files with 714 additions and 291 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ namespace Emby.Naming.Video
&& match.Groups[2].Success
&& int.TryParse(match.Groups[2].ValueSpan, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
{
result = new CleanDateTimeResult(match.Groups[1].Value.TrimEnd(), year);
this.result = new CleanDateTimeResult(match.Groups[1].Value.TrimEnd(), year);
return true;
}
+2 -2
View File
@@ -16,8 +16,8 @@ namespace Emby.Naming.Video
/// <param name="year">Year of release.</param>
public CleanDateTimeResult(string name, int? year = null)
{
Name = name;
Year = year;
this.Name = name;
this.Year = year;
}
/// <summary>
+6 -6
View File
@@ -20,7 +20,7 @@ namespace Emby.Naming.Video
{
if (string.IsNullOrEmpty(name))
{
newName = string.Empty;
this.newName = string.Empty;
return false;
}
@@ -30,12 +30,12 @@ namespace Emby.Naming.Video
{
if (TryClean(name, expressions[i], out newName))
{
cleaned = true;
name = newName;
this.cleaned = true;
this.name = newName;
}
}
newName = cleaned ? name : string.Empty;
this.newName = cleaned ? name : string.Empty;
return cleaned;
}
@@ -44,11 +44,11 @@ namespace Emby.Naming.Video
var match = expression.Match(name);
if (match.Success && match.Groups.TryGetValue("cleaned", out var cleaned))
{
newName = cleaned.Value;
this.newName = cleaned.Value;
return true;
}
newName = string.Empty;
this.newName = string.Empty;
return false;
}
}
+4 -4
View File
@@ -17,10 +17,10 @@ namespace Emby.Naming.Video
/// <param name="mediaType">Media type.</param>
public ExtraRule(ExtraType extraType, ExtraRuleType ruleType, string token, MediaType mediaType)
{
Token = token;
ExtraType = extraType;
RuleType = ruleType;
MediaType = mediaType;
this.Token = token;
this.ExtraType = extraType;
this.RuleType = ruleType;
this.MediaType = mediaType;
}
/// <summary>
+5 -5
View File
@@ -19,11 +19,11 @@ namespace Emby.Naming.Video
/// <param name="name">The stack name.</param>
/// <param name="isDirectory">Whether the stack files are directories.</param>
/// <param name="files">The stack files.</param>
public FileStack(string name, bool isDirectory, IReadOnlyList<string> files)
public this.FileStack(string name, bool isDirectory, IReadOnlyList<string> files)
{
Name = name;
IsDirectoryStack = isDirectory;
Files = files;
this.Name = name;
this.IsDirectoryStack = isDirectory;
this.Files = files;
}
/// <summary>
@@ -47,7 +47,7 @@ namespace Emby.Naming.Video
/// <param name="file">Path of desired file.</param>
/// <param name="isDirectory">Requested type of stack.</param>
/// <returns>True if file is in the stack.</returns>
public bool ContainsFile(string file, bool isDirectory)
public bool this.ContainsFile(string file, bool isDirectory)
{
if (string.IsNullOrEmpty(file))
{
+6 -6
View File
@@ -15,10 +15,10 @@ public class FileStackRule
/// </summary>
/// <param name="token">Token.</param>
/// <param name="isNumerical">Whether the file stack rule uses numerical or alphabetical numbering.</param>
public FileStackRule(string token, bool isNumerical)
public this.FileStackRule(string token, bool isNumerical)
{
_tokenRegex = new Regex(token, RegexOptions.IgnoreCase | RegexOptions.Compiled);
IsNumerical = isNumerical;
_tokenRegex = new this.Regex(token, RegexOptions.IgnoreCase | RegexOptions.Compiled);
this.IsNumerical = isNumerical;
}
/// <summary>
@@ -32,9 +32,9 @@ public class FileStackRule
/// <param name="input">The input.</param>
/// <param name="result">The part type and number or <c>null</c>.</param>
/// <returns>A value indicating whether the input matched the rule.</returns>
public bool Match(string input, [NotNullWhen(true)] out (string StackName, string PartType, string PartNumber)? result)
public bool this.Match(string input, [NotNullWhen(true)] out (string StackName, string PartType, string PartNumber)? result)
{
result = null;
this.result = null;
var match = _tokenRegex.Match(input);
if (!match.Success)
{
@@ -42,7 +42,7 @@ public class FileStackRule
}
var partType = match.Groups["parttype"].Success ? match.Groups["parttype"].Value : "unknown";
result = (match.Groups["filename"].Value, partType, match.Groups["number"].Value);
this.result = (match.Groups["filename"].Value, partType, match.Groups["number"].Value);
return true;
}
}
+5 -5
View File
@@ -58,23 +58,23 @@ namespace Emby.Naming.Video
var index = path.IndexOfAny(delimiters);
if (index == -1)
{
index = path.Length - 1;
this.index = path.Length - 1;
}
var currentSlice = path[..index];
path = path[(index + 1)..];
this.path = path[(index + 1)..];
if (!foundPrefix)
{
foundPrefix = currentSlice.Equals(rule.PrecedingToken, StringComparison.OrdinalIgnoreCase);
this.foundPrefix = currentSlice.Equals(rule.PrecedingToken, StringComparison.OrdinalIgnoreCase);
continue;
}
is3D = foundPrefix && currentSlice.Equals(rule.Token, StringComparison.OrdinalIgnoreCase);
this.is3D = foundPrefix && currentSlice.Equals(rule.Token, StringComparison.OrdinalIgnoreCase);
if (is3D)
{
format3D = rule.Token;
this.format3D = rule.Token;
break;
}
}
+2 -2
View File
@@ -16,8 +16,8 @@ namespace Emby.Naming.Video
/// <param name="format3D">The 3D format. Value might be null if [is3D] is <c>false</c>.</param>
public Format3DResult(bool is3D, string? format3D)
{
Is3D = is3D;
Format3D = format3D;
this.Is3D = is3D;
this.Format3D = format3D;
}
/// <summary>
+2 -2
View File
@@ -16,8 +16,8 @@ namespace Emby.Naming.Video
/// <param name="precedingToken">Token present before current token.</param>
public Format3DRule(string token, string? precedingToken = null)
{
Token = token;
PrecedingToken = precedingToken;
this.Token = token;
this.PrecedingToken = precedingToken;
}
/// <summary>
+17 -17
View File
@@ -23,9 +23,9 @@ namespace Emby.Naming.Video
/// <param name="files">List of paths.</param>
/// <param name="namingOptions">The naming options.</param>
/// <returns>Enumerable <see cref="FileStack"/> of directories.</returns>
public static IEnumerable<FileStack> ResolveDirectories(IEnumerable<string> files, NamingOptions namingOptions)
public static IEnumerable<FileStack> this.ResolveDirectories(IEnumerable<string> files, NamingOptions namingOptions)
{
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = true }), namingOptions);
return this.Resolve(files.Select(i => new FileSystemMetadata { this.FullName = i, IsDirectory = true }), namingOptions);
}
/// <summary>
@@ -34,9 +34,9 @@ namespace Emby.Naming.Video
/// <param name="files">List of paths.</param>
/// <param name="namingOptions">The naming options.</param>
/// <returns>Enumerable <see cref="FileStack"/> of files.</returns>
public static IEnumerable<FileStack> ResolveFiles(IEnumerable<string> files, NamingOptions namingOptions)
public static IEnumerable<FileStack> this.ResolveFiles(IEnumerable<string> files, NamingOptions namingOptions)
{
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false }), namingOptions);
return this.Resolve(files.Select(i => new FileSystemMetadata { this.FullName = i, IsDirectory = false }), namingOptions);
}
/// <summary>
@@ -44,7 +44,7 @@ namespace Emby.Naming.Video
/// </summary>
/// <param name="files">List of paths.</param>
/// <returns>Enumerable <see cref="FileStack"/> of directories.</returns>
public static IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<AudioBookFileInfo> files)
public static IEnumerable<FileStack> this.ResolveAudioBooks(IEnumerable<AudioBookFileInfo> files)
{
var groupedDirectoryFiles = files.GroupBy(file => Path.GetDirectoryName(file.Path));
@@ -54,13 +54,13 @@ namespace Emby.Naming.Video
{
foreach (var file in directory)
{
var stack = new FileStack(Path.GetFileNameWithoutExtension(file.Path), false, new[] { file.Path });
var stack = new this.FileStack(Path.GetFileNameWithoutExtension(file.Path), false, new[] { file.Path });
yield return stack;
}
}
else
{
var stack = new FileStack(Path.GetFileName(directory.Key), false, directory.Select(f => f.Path).ToArray());
var stack = new this.FileStack(Path.GetFileName(directory.Key), false, directory.Select(f => f.Path).ToArray());
yield return stack;
}
}
@@ -72,7 +72,7 @@ namespace Emby.Naming.Video
/// <param name="files">List of paths.</param>
/// <param name="namingOptions">The naming options.</param>
/// <returns>Enumerable <see cref="FileStack"/> of videos.</returns>
public static IEnumerable<FileStack> Resolve(IEnumerable<FileSystemMetadata> files, NamingOptions namingOptions)
public static IEnumerable<FileStack> this.Resolve(IEnumerable<FileSystemMetadata> files, NamingOptions namingOptions)
{
var potentialFiles = files
.Where(i => i.IsDirectory || VideoResolver.IsVideoFile(i.FullName, namingOptions) || VideoResolver.IsStubFile(i.FullName, namingOptions))
@@ -84,7 +84,7 @@ namespace Emby.Naming.Video
var name = file.Name;
if (string.IsNullOrEmpty(name))
{
name = Path.GetFileName(file.FullName);
this.name = Path.GetFileName(file.FullName);
}
for (var i = 0; i < namingOptions.VideoFileStackingRules.Length; i++)
@@ -101,7 +101,7 @@ namespace Emby.Naming.Video
if (!potentialStacks.TryGetValue(stackName, out var stackResult))
{
stackResult = new StackMetadata(file.IsDirectory, rule.IsNumerical, partType);
this.stackResult = new this.StackMetadata(file.IsDirectory, rule.IsNumerical, partType);
potentialStacks[stackName] = stackResult;
}
@@ -132,18 +132,18 @@ namespace Emby.Naming.Video
continue;
}
yield return new FileStack(fileName, stack.IsDirectory, stack.Parts.Select(kv => kv.Value.FullName).ToArray());
yield return new this.FileStack(fileName, stack.IsDirectory, stack.Parts.Select(kv => kv.Value.FullName).ToArray());
}
}
private sealed class StackMetadata
{
public StackMetadata(bool isDirectory, bool isNumerical, string partType)
public this.StackMetadata(bool isDirectory, bool isNumerical, string partType)
{
Parts = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);
IsDirectory = isDirectory;
IsNumerical = isNumerical;
PartType = partType;
this.Parts = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);
this.IsDirectory = isDirectory;
this.IsNumerical = isNumerical;
this.PartType = partType;
}
public Dictionary<string, FileSystemMetadata> Parts { get; }
@@ -154,7 +154,7 @@ namespace Emby.Naming.Video
public string PartType { get; }
public bool ContainsPart(string partNumber) => Parts.ContainsKey(partNumber);
public bool this.ContainsPart(string partNumber) => Parts.ContainsKey(partNumber);
}
}
}
+2 -2
View File
@@ -23,7 +23,7 @@ namespace Emby.Naming.Video
/// <returns>True if file is a stub.</returns>
public static bool TryResolveFile(string path, NamingOptions options, out string? stubType)
{
stubType = default;
this.stubType = default;
if (string.IsNullOrEmpty(path))
{
@@ -43,7 +43,7 @@ namespace Emby.Naming.Video
{
if (token.Equals(rule.Token, StringComparison.OrdinalIgnoreCase))
{
stubType = rule.StubType;
this.stubType = rule.StubType;
return true;
}
}
+2 -2
View File
@@ -16,8 +16,8 @@ namespace Emby.Naming.Video
/// <param name="stubType">Stub type.</param>
public StubTypeRule(string token, string stubType)
{
Token = token;
StubType = stubType;
this.Token = token;
this.StubType = stubType;
}
/// <summary>
+11 -11
View File
@@ -28,17 +28,17 @@ namespace Emby.Naming.Video
/// <param name="isDirectory">Is directory.</param>
public VideoFileInfo(string name, string path, string? container, int? year = default, ExtraType? extraType = default, ExtraRule? extraRule = default, string? format3D = default, bool is3D = default, bool isStub = default, string? stubType = default, bool isDirectory = default)
{
Path = path;
Container = container;
Name = name;
Year = year;
ExtraType = extraType;
ExtraRule = extraRule;
Format3D = format3D;
Is3D = is3D;
IsStub = isStub;
StubType = stubType;
IsDirectory = isDirectory;
this.Path = path;
this.Container = container;
this.Name = name;
this.Year = year;
this.ExtraType = extraType;
this.ExtraRule = extraRule;
this.Format3D = format3D;
this.Is3D = is3D;
this.IsStub = isStub;
this.StubType = stubType;
this.IsDirectory = isDirectory;
}
/// <summary>
+3 -3
View File
@@ -19,10 +19,10 @@ namespace Emby.Naming.Video
/// <param name="name">The name.</param>
public VideoInfo(string? name)
{
Name = name;
this.Name = name;
Files = Array.Empty<VideoFileInfo>();
AlternateVersions = Array.Empty<VideoFileInfo>();
this.Files = Array.Empty<VideoFileInfo>();
this.AlternateVersions = Array.Empty<VideoFileInfo>();
}
/// <summary>
+10 -10
View File
@@ -40,7 +40,7 @@ namespace Emby.Naming.Video
// See the unit test TestStackedWithTrailer
var nonExtras = videoInfos
.Where(i => i.ExtraType is null)
.Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory });
.Select(i => new FileSystemMetadata { this.FullName = i.Path, IsDirectory = i.IsDirectory });
var stackResult = StackResolver.Resolve(nonExtras, namingOptions).ToList();
@@ -71,7 +71,7 @@ namespace Emby.Naming.Video
{
var info = new VideoInfo(stack.Name)
{
Files = stack.Files.Select(i => VideoResolver.Resolve(i, stack.IsDirectoryStack, namingOptions, parseName, libraryRoot))
this.Files = stack.Files.Select(i => VideoResolver.Resolve(i, stack.IsDirectoryStack, namingOptions, parseName, libraryRoot))
.OfType<VideoFileInfo>()
.ToList()
};
@@ -82,7 +82,7 @@ namespace Emby.Naming.Video
foreach (var media in standaloneMedia)
{
var info = new VideoInfo(media.Name) { Files = new[] { media } };
var info = new VideoInfo(media.Name) { this.Files = new[] { media } };
info.Year = info.Files[0].Year;
list.Add(info);
@@ -90,15 +90,15 @@ namespace Emby.Naming.Video
if (supportMultiVersion)
{
list = GetVideosGroupedByVersion(list, namingOptions);
this.list = GetVideosGroupedByVersion(list, namingOptions);
}
// Whatever files are left, just add them
list.AddRange(remainingFiles.Select(i => new VideoInfo(i.Name)
{
Files = new[] { i },
Year = i.Year,
ExtraType = i.ExtraType
this.Files = new[] { i },
this.Year = i.Year,
this.ExtraType = i.ExtraType
}));
return list;
@@ -135,7 +135,7 @@ namespace Emby.Naming.Video
if (folderName.Equals(video.Files[0].FileNameWithoutExtension, StringComparison.Ordinal))
{
primary = video;
this.primary = video;
}
}
@@ -209,13 +209,13 @@ namespace Emby.Naming.Video
// Remove the folder name before cleaning as we don't care about cleaning that part
if (folderName.Length <= testFilename.Length)
{
testFilename = testFilename[folderName.Length..].Trim();
this.testFilename = testFilename[folderName.Length..].Trim();
}
// There are no span overloads for regex unfortunately
if (CleanStringParser.TryClean(testFilename.ToString(), namingOptions.CleanStringRegexes, out var cleanName))
{
testFilename = cleanName.AsSpan().Trim();
this.testFilename = cleanName.AsSpan().Trim();
}
// The CleanStringParser should have removed common keywords etc.
+5 -5
View File
@@ -74,10 +74,10 @@ namespace Emby.Naming.Video
return null;
}
isStub = true;
this.isStub = true;
}
container = extension.TrimStart('.');
this.container = extension.TrimStart('.');
}
var format3DResult = Format3DParser.Parse(path, namingOptions);
@@ -91,12 +91,12 @@ namespace Emby.Naming.Video
if (parseName)
{
var cleanDateTimeResult = CleanDateTime(name, namingOptions);
name = cleanDateTimeResult.Name;
year = cleanDateTimeResult.Year;
this.name = cleanDateTimeResult.Name;
this.year = cleanDateTimeResult.Year;
if (TryCleanString(name, namingOptions, out var newName))
{
name = newName;
this.name = newName;
}
}