mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
set langversion to latest, and enable nullable types in all projects
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<EmitCompilerGeneratedFiles>false</EmitCompilerGeneratedFiles>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="certificates\*.cer" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CompatApiClient\CompatApiClient.csproj" />
|
||||
|
||||
@@ -65,13 +65,13 @@ public class AttributeUsageAnalyzer : DiagnosticAnalyzer
|
||||
private static bool IsDescendantOfAttribute(AttributeData attributeData, string baseAttributeClassNameWithNamespace)
|
||||
{
|
||||
var attrClass = attributeData.AttributeClass;
|
||||
do
|
||||
while (attrClass is not null)
|
||||
{
|
||||
if (attrClass.ToDisplayString() == baseAttributeClassNameWithNamespace)
|
||||
return true;
|
||||
|
||||
attrClass = attrClass.BaseType;
|
||||
} while (attrClass != null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<NoWarn>1701;1702;RS2008;RS1036</NoWarn>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Win32ErrorsSourceGenerator : ISourceGenerator
|
||||
previousPos = (int)stream.Position;
|
||||
|
||||
var name = nameDescParts[0];
|
||||
var desc = nameDescParts[1].Replace("\\", "\\\\").Replace("\"", "\\\"");
|
||||
var desc = nameDescParts[1].Replace(@"\", @"\\").Replace("\"", "\\\"");
|
||||
result.AppendLine($"{Indent}{Indent}{Indent}[{errorCodeLine.Trim()}] = (\"{name.Trim()}\", \"{desc.Trim()}\"),");
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public class MemoryCacheExtensionTests
|
||||
cache.Set(13, testVal);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(cache.TryGetValue(13, out string expectedVal), Is.True);
|
||||
Assert.That(cache.TryGetValue(13, out string? expectedVal), Is.True);
|
||||
Assert.That(expectedVal, Is.EqualTo(testVal));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DuoVia.FuzzyStrings" Version="2.1.0" />
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ZalgoTests
|
||||
public async Task ZalgoAuditTestAsync()
|
||||
{
|
||||
var samplePath = @"C:/Users/13xforever/Downloads/names.txt";
|
||||
var resultPath = Path.Combine(Path.GetDirectoryName(samplePath), "zalgo.txt");
|
||||
var resultPath = Path.Combine(Path.GetDirectoryName(samplePath)!, "zalgo.txt");
|
||||
|
||||
var names = await File.ReadAllLinesAsync(samplePath, Encoding.UTF8);
|
||||
await using var r = File.Open(resultPath, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
@@ -43,7 +43,7 @@ public class ZalgoTests
|
||||
public async Task RoleSortTestAsync()
|
||||
{
|
||||
var samplePath = @"C:/Users/13xforever/Downloads/names.txt";
|
||||
var resultPath = Path.Combine(Path.GetDirectoryName(samplePath), "role_count.txt");
|
||||
var resultPath = Path.Combine(Path.GetDirectoryName(samplePath)!, "role_count.txt");
|
||||
|
||||
var stats = new int[10];
|
||||
var names = await File.ReadAllLinesAsync(samplePath, Encoding.UTF8);
|
||||
@@ -82,7 +82,7 @@ public class ZalgoTests
|
||||
[TestCase("͔", true, "Combining marks")]
|
||||
[TestCase("҉҉҉҉", true, "Combining sign")]
|
||||
[TestCase(" ", true, "Private block")]
|
||||
public void ZalgoDetectionTest(string name, bool isBad, string comment = null)
|
||||
public void ZalgoDetectionTest(string name, bool isBad, string? comment = null)
|
||||
{
|
||||
Assert.That(UsernameZalgoMonitor.NeedsRename(name), Is.EqualTo(isBad), comment);
|
||||
}
|
||||
@@ -90,10 +90,10 @@ public class ZalgoTests
|
||||
|
||||
internal class UserInfo
|
||||
{
|
||||
public string Username { get; private set; }
|
||||
public string Nickname { get; private set; }
|
||||
public DateTime JoinDate { get; private set; }
|
||||
public string[] Roles { get; private set; }
|
||||
public string Username { get; private init; } = null!;
|
||||
public string Nickname { get; private init; } = null!;
|
||||
public DateTime JoinDate { get; private init; }
|
||||
public string[] Roles { get; private init; } = null!;
|
||||
|
||||
public string DisplayName => string.IsNullOrEmpty(Nickname) ? Username : Nickname;
|
||||
|
||||
@@ -108,7 +108,7 @@ internal class UserInfo
|
||||
Username = parts[0],
|
||||
Nickname = parts[1],
|
||||
JoinDate = DateTime.Parse(parts[2], CultureInfo.InvariantCulture),
|
||||
Roles = parts[3]?.Split(',', StringSplitOptions.RemoveEmptyEntries) ?? [],
|
||||
Roles = parts[3].Split(',', StringSplitOptions.RemoveEmptyEntries),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user