Remove static ToFile
MODIFY
WalletWasabi.Tests/UnitTests/LegalTests.cs
WalletWasabi.Tests/UnitTests/LegalTests.cs
@@ -149,20 +149,6 @@ namespace WalletWasabi.Tests.UnitTests
Assert.Equal(Path.Combine(legalDir, $"{version}.txt"), res.FilePath);
}
- [Fact]
- public async Task LegalDocFileNameMustBeProperlyFormattedAsync()
- {
- var dir = Path.Combine(Global.Instance.DataDir, EnvironmentHelpers.GetCallerFileName());
- if (Directory.Exists(dir))
- {
- Directory.Delete(dir, true);
- }
-
- await Assert.ThrowsAsync<ArgumentException>(async () => await LegalDocuments.ToFileAsync(Path.Combine("foo"), "bar"));
- await Assert.ThrowsAsync<ArgumentException>(async () => await LegalDocuments.ToFileAsync(Path.Combine("foo.txt"), "bar"));
- await Assert.ThrowsAsync<ArgumentException>(async () => await LegalDocuments.ToFileAsync(Path.Combine("1.txt"), "bar"));
- }
-
[Fact]
public async Task CanSerializeFileAsync()
{

MODIFY
WalletWasabi/Legal/LegalDocuments.cs
WalletWasabi/Legal/LegalDocuments.cs
@@ -56,16 +56,6 @@ namespace WalletWasabi.Legal
.Where(x => Version.TryParse(Path.GetFileNameWithoutExtension(x), out _));
}
- public async static Task ToFileAsync(string filePath, string content)
- {
- // Throw exception if filepath is incorrectly formatted.
- Version.Parse(Path.GetFileNameWithoutExtension(filePath));
-
- var legalFolderPath = Path.GetDirectoryName(filePath);
- RemoveCandidates(legalFolderPath);
- await File.WriteAllTextAsync(filePath, content).ConfigureAwait(false);
- }
-
private static void RemoveCandidates(string legalFolderPath)
{
IoHelpers.EnsureDirectoryExists(legalFolderPath);
@@ -76,6 +66,11 @@ namespace WalletWasabi.Legal
}
}
- public async Task ToFileAsync(string content) => await ToFileAsync(FilePath, content).ConfigureAwait(false);
+ public async Task ToFileAsync(string content)
+ {
+ var legalFolderPath = Path.GetDirectoryName(FilePath);
+ RemoveCandidates(legalFolderPath);
+ await File.WriteAllTextAsync(FilePath, content).ConfigureAwait(false);
+ }
}
}

Remove static ToFile