diff --git a/.editorconfig b/.editorconfig
index 426c83c..a717a9a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -4,8 +4,8 @@ root = true
charset = utf-8
indent_size = 4
indent_style = space
-insert_final_newline = true
trim_trailing_whitespace = true
+insert_final_newline = true
[*.{yml,yaml}]
indent_size = 2
@@ -28,62 +28,18 @@ csharp_style_var_elsewhere = true:suggestion
# Indentation preferences
csharp_indent_labels = no_change
-# IDE0059: Unnecessary assigment of a value
-dotnet_diagnostic.IDE0059.severity = none
-
-# IDE0060: Remove unused parameter
-dotnet_diagnostic.IDE0060.severity = none
-
-# IDE0079: Remove unnecessary suppression
-# dotnet_diagnostic.IDE0079.severity = none
-
# IDE0079: Remove unnecessary suppression
dotnet_remove_unnecessary_suppression_exclusions = category:ReSharper
-# CS8600: Converting null literal or possible null value to non-nullable type.
-dotnet_diagnostic.CS8600.severity = error
-
-# CS8601: Possible null reference assignment.
-dotnet_diagnostic.CS8601.severity = error
-
-# CS8602: Dereference of a possibly null reference.
-dotnet_diagnostic.CS8602.severity = error
-
-# CS8603: Possible null reference return.
-dotnet_diagnostic.CS8603.severity = error
-
-# CS8604: Possible null reference argument.
-dotnet_diagnostic.CS8604.severity = error
-
-# CS8610: Nullability of reference types in type of parameter doesn't match overridden member.
-dotnet_diagnostic.CS8610.severity = error
-
-# CS8613: Nullability of reference types in return type doesn't match implicitly implemented member.
-dotnet_diagnostic.CS8613.severity = error
-
-# CS8614: Nullability of reference types in type of parameter doesn't match implicitly implemented member.
-dotnet_diagnostic.CS8614.severity = error
-
-# CS8618: Non-nullable field is uninitialized. Consider declaring as nullable.
-dotnet_diagnostic.CS8618.severity = error
-
-# CS8619: Nullability of reference types in value doesn't match target type.
-dotnet_diagnostic.CS8619.severity = error
-
-# CS8620: Argument cannot be used for parameter due to differences in the nullability of reference types.
-dotnet_diagnostic.CS8620.severity = error
-
-# CS8625: Cannot convert null literal to non-nullable reference type.
-dotnet_diagnostic.CS8625.severity = error
-
-# CS8634: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'class' constraint.
-dotnet_diagnostic.CS8634.severity = error
-
-# CS8643: Nullability of reference types in explicit interface specifier doesn't match interface implemented by the type.
-dotnet_diagnostic.CS8643.severity = error
+[tests/**.cs]
+# CA1707: Identifiers should not contain underscores
+# Tests follow the Method_Condition_ExpectedResult naming convention.
+dotnet_diagnostic.CA1707.severity = none
-# CS8653: A default expression introduces a null value for a type parameter.
-dotnet_diagnostic.CS8653.severity = error
+# CA1001: Types that own disposable fields should be disposable
+# Test fixtures release their resources in [OneTimeTearDown] methods, which the rule does not recognize.
+dotnet_diagnostic.CA1001.severity = none
-# CS8714: The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'notnull' constraint.
-dotnet_diagnostic.CS8714.severity = error
+# CA1716: Identifiers should not match keywords
+# Test namespaces match the namespaces of the code under test.
+dotnet_diagnostic.CA1716.severity = none
diff --git a/Directory.Build.props b/Directory.Build.props
index ed14ea7..9e6caca 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -2,4 +2,18 @@
true
+
+
+ $(NoWarn);CS0649
+ true
+
+
+
+ true
+ latest
+ Recommended
+ Default
+ true
+ true
+
diff --git a/src/Ramstack.FileSystem.Abstractions/Ramstack.FileSystem.Abstractions.csproj b/src/Ramstack.FileSystem.Abstractions/Ramstack.FileSystem.Abstractions.csproj
index 6f50f5e..844005b 100644
--- a/src/Ramstack.FileSystem.Abstractions/Ramstack.FileSystem.Abstractions.csproj
+++ b/src/Ramstack.FileSystem.Abstractions/Ramstack.FileSystem.Abstractions.csproj
@@ -11,11 +11,6 @@
Ramstack.FileSystem
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Adapters/Ramstack.FileSystem.Adapters.csproj b/src/Ramstack.FileSystem.Adapters/Ramstack.FileSystem.Adapters.csproj
index 0934aae..0a9d486 100644
--- a/src/Ramstack.FileSystem.Adapters/Ramstack.FileSystem.Adapters.csproj
+++ b/src/Ramstack.FileSystem.Adapters/Ramstack.FileSystem.Adapters.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Amazon/Ramstack.FileSystem.Amazon.csproj b/src/Ramstack.FileSystem.Amazon/Ramstack.FileSystem.Amazon.csproj
index 8341790..b8d2184 100644
--- a/src/Ramstack.FileSystem.Amazon/Ramstack.FileSystem.Amazon.csproj
+++ b/src/Ramstack.FileSystem.Amazon/Ramstack.FileSystem.Amazon.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Amazon/S3UploadStream.cs b/src/Ramstack.FileSystem.Amazon/S3UploadStream.cs
index 86c7e8c..a309f85 100644
--- a/src/Ramstack.FileSystem.Amazon/S3UploadStream.cs
+++ b/src/Ramstack.FileSystem.Amazon/S3UploadStream.cs
@@ -162,6 +162,8 @@ protected override void Dispose(bool disposing)
}
///
+ [SuppressMessage("Usage", "CA2215:Dispose methods should call base class dispose",
+ Justification = "Stream.DisposeAsync only calls Dispose, which re-enters this method, and the base Stream releases nothing on disposal.")]
public override async ValueTask DisposeAsync()
{
if (Interlocked.Exchange(ref _disposed, 1) != 0)
diff --git a/src/Ramstack.FileSystem.Azure/Ramstack.FileSystem.Azure.csproj b/src/Ramstack.FileSystem.Azure/Ramstack.FileSystem.Azure.csproj
index e010189..23af901 100644
--- a/src/Ramstack.FileSystem.Azure/Ramstack.FileSystem.Azure.csproj
+++ b/src/Ramstack.FileSystem.Azure/Ramstack.FileSystem.Azure.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Composite/Ramstack.FileSystem.Composite.csproj b/src/Ramstack.FileSystem.Composite/Ramstack.FileSystem.Composite.csproj
index 7d705ba..8cf967f 100644
--- a/src/Ramstack.FileSystem.Composite/Ramstack.FileSystem.Composite.csproj
+++ b/src/Ramstack.FileSystem.Composite/Ramstack.FileSystem.Composite.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Globbing/Ramstack.FileSystem.Globbing.csproj b/src/Ramstack.FileSystem.Globbing/Ramstack.FileSystem.Globbing.csproj
index c52f674..ae3abf2 100644
--- a/src/Ramstack.FileSystem.Globbing/Ramstack.FileSystem.Globbing.csproj
+++ b/src/Ramstack.FileSystem.Globbing/Ramstack.FileSystem.Globbing.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Google/Ramstack.FileSystem.Google.csproj b/src/Ramstack.FileSystem.Google/Ramstack.FileSystem.Google.csproj
index c385801..ad4e3f7 100644
--- a/src/Ramstack.FileSystem.Google/Ramstack.FileSystem.Google.csproj
+++ b/src/Ramstack.FileSystem.Google/Ramstack.FileSystem.Google.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Physical/Ramstack.FileSystem.Physical.csproj b/src/Ramstack.FileSystem.Physical/Ramstack.FileSystem.Physical.csproj
index 48d134f..4580cdd 100644
--- a/src/Ramstack.FileSystem.Physical/Ramstack.FileSystem.Physical.csproj
+++ b/src/Ramstack.FileSystem.Physical/Ramstack.FileSystem.Physical.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Prefixed/PrefixedDirectory.cs b/src/Ramstack.FileSystem.Prefixed/PrefixedDirectory.cs
index 4db5ca8..b4e0b3f 100644
--- a/src/Ramstack.FileSystem.Prefixed/PrefixedDirectory.cs
+++ b/src/Ramstack.FileSystem.Prefixed/PrefixedDirectory.cs
@@ -6,7 +6,7 @@ namespace Ramstack.FileSystem.Prefixed;
/// Represents a directory in a ,
/// wrapping an existing instance with a prefixed path.
///
-internal class PrefixedDirectory : VirtualDirectory
+internal sealed class PrefixedDirectory : VirtualDirectory
{
private readonly PrefixedFileSystem _fs;
private readonly VirtualDirectory _directory;
diff --git a/src/Ramstack.FileSystem.Prefixed/Ramstack.FileSystem.Prefixed.csproj b/src/Ramstack.FileSystem.Prefixed/Ramstack.FileSystem.Prefixed.csproj
index dad5ac7..eaf9bff 100644
--- a/src/Ramstack.FileSystem.Prefixed/Ramstack.FileSystem.Prefixed.csproj
+++ b/src/Ramstack.FileSystem.Prefixed/Ramstack.FileSystem.Prefixed.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Readonly/GlobalSuppressions.cs b/src/Ramstack.FileSystem.Readonly/GlobalSuppressions.cs
new file mode 100644
index 0000000..67ae6e0
--- /dev/null
+++ b/src/Ramstack.FileSystem.Readonly/GlobalSuppressions.cs
@@ -0,0 +1,5 @@
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: SuppressMessage("Naming", "CA1716:Identifiers should not match keywords",
+ Scope = "namespace", Target = "~N:Ramstack.FileSystem.Readonly",
+ Justification = "The namespace matches the package name, and renaming it would break the public API.")]
diff --git a/src/Ramstack.FileSystem.Readonly/Ramstack.FileSystem.Readonly.csproj b/src/Ramstack.FileSystem.Readonly/Ramstack.FileSystem.Readonly.csproj
index e8c756c..6a2a384 100644
--- a/src/Ramstack.FileSystem.Readonly/Ramstack.FileSystem.Readonly.csproj
+++ b/src/Ramstack.FileSystem.Readonly/Ramstack.FileSystem.Readonly.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/src/Ramstack.FileSystem.Sub/GlobalSuppressions.cs b/src/Ramstack.FileSystem.Sub/GlobalSuppressions.cs
new file mode 100644
index 0000000..6473e8b
--- /dev/null
+++ b/src/Ramstack.FileSystem.Sub/GlobalSuppressions.cs
@@ -0,0 +1,5 @@
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: SuppressMessage("Naming", "CA1716:Identifiers should not match keywords",
+ Scope = "namespace", Target = "~N:Ramstack.FileSystem.Sub",
+ Justification = "The namespace matches the package name, and renaming it would break the public API.")]
diff --git a/src/Ramstack.FileSystem.Sub/Ramstack.FileSystem.Sub.csproj b/src/Ramstack.FileSystem.Sub/Ramstack.FileSystem.Sub.csproj
index ade88ac..6fcaf69 100644
--- a/src/Ramstack.FileSystem.Sub/Ramstack.FileSystem.Sub.csproj
+++ b/src/Ramstack.FileSystem.Sub/Ramstack.FileSystem.Sub.csproj
@@ -10,11 +10,6 @@
true
-
- 649;1591
- CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8613;CS8614;CS8618;CS8619;CS8620;CS8625;CS8643;CS8653;CS8714
-
-
https://github.com/rameel/ramstack.filesystem
Rameel
diff --git a/tests/Ramstack.FileSystem.Amazon.Tests/WritableAmazonFileSystemTests.cs b/tests/Ramstack.FileSystem.Amazon.Tests/WritableAmazonFileSystemTests.cs
index 6fdbc49..88d5a87 100644
--- a/tests/Ramstack.FileSystem.Amazon.Tests/WritableAmazonFileSystemTests.cs
+++ b/tests/Ramstack.FileSystem.Amazon.Tests/WritableAmazonFileSystemTests.cs
@@ -116,11 +116,9 @@ await file.GetLengthAsync(),
var count = 0;
- while (!reader.EndOfStream)
+ while (await reader.ReadLineAsync() is { } line)
{
- Assert.That(
- await reader.ReadLineAsync(),
- Is.EqualTo(value));
+ Assert.That(line, Is.EqualTo(value));
count++;
}
diff --git a/tests/Ramstack.FileSystem.Google.Tests/WritableGoogleFileSystemTests.cs b/tests/Ramstack.FileSystem.Google.Tests/WritableGoogleFileSystemTests.cs
index 8657e17..bb844f1 100644
--- a/tests/Ramstack.FileSystem.Google.Tests/WritableGoogleFileSystemTests.cs
+++ b/tests/Ramstack.FileSystem.Google.Tests/WritableGoogleFileSystemTests.cs
@@ -114,11 +114,9 @@ await file.GetLengthAsync(),
var count = 0;
- while (!reader.EndOfStream)
+ while (await reader.ReadLineAsync() is { } line)
{
- Assert.That(
- await reader.ReadLineAsync(),
- Is.EqualTo(value));
+ Assert.That(line, Is.EqualTo(value));
count++;
}
diff --git a/tests/Ramstack.FileSystem.Specification.Tests/Utilities/TempFileStorage.cs b/tests/Ramstack.FileSystem.Specification.Tests/Utilities/TempFileStorage.cs
index db18781..f5d6681 100644
--- a/tests/Ramstack.FileSystem.Specification.Tests/Utilities/TempFileStorage.cs
+++ b/tests/Ramstack.FileSystem.Specification.Tests/Utilities/TempFileStorage.cs
@@ -7,8 +7,8 @@ public sealed class TempFileStorage : IDisposable
public TempFileStorage()
{
var path = Root;
- var list = new[]
- {
+ string[] files =
+ [
"project/docs/user_manual.pdf",
"project/docs/api_reference.md",
"project/docs/troubleshooting/common_issues.txt",
@@ -79,7 +79,9 @@ public TempFileStorage()
"project/README.md",
"project/global.json",
"project/nuget.config",
- }
+ ];
+
+ var list = files
.Select(p => Path.Combine(path, p))
.ToArray();
diff --git a/tests/Ramstack.FileSystem.Specification.Tests/VirtualFileSystemSpecificationTests.cs b/tests/Ramstack.FileSystem.Specification.Tests/VirtualFileSystemSpecificationTests.cs
index 6713405..53ec23b 100644
--- a/tests/Ramstack.FileSystem.Specification.Tests/VirtualFileSystemSpecificationTests.cs
+++ b/tests/Ramstack.FileSystem.Specification.Tests/VirtualFileSystemSpecificationTests.cs
@@ -24,8 +24,9 @@ public async Task FileTree_MatchesStructure()
static async Task CompareDirectoriesAsync(VirtualDirectory virtualDir, DirectoryInfo localDir)
{
- if (await virtualDir.ExistsAsync() != localDir.Exists)
- Assert.Fail($"Directory '{virtualDir.FullName}'.Exists ({virtualDir.ExistsAsync().Result}) != '{localDir.FullName}'.Exists ({localDir.Exists})");
+ var exists = await virtualDir.ExistsAsync();
+ if (exists != localDir.Exists)
+ Assert.Fail($"Directory '{virtualDir.FullName}'.Exists ({exists}) != '{localDir.FullName}'.Exists ({localDir.Exists})");
var virtualFiles = await virtualDir.GetFilesAsync().OrderBy(f => f.Name).ToArrayAsync();
var localFiles = localDir.EnumerateFiles().OrderBy(f => f.Name).ToArray();