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
Use nullable references in security rules #3110
Conversation
src/Microsoft.NetFramework.Analyzers/Core/Helpers/SecurityDiagnosticHelpers.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.NetFramework.Analyzers/Core/Helpers/SecurityDiagnosticHelpers.cs
Outdated
Show resolved
Hide resolved
@@ -274,7 +277,7 @@ public static string GetNonEmptyParentName(SyntaxNode current, SemanticModel mod | |||
/// For .NET Framework 4.X, this method returns the actual framework version instead of assembly verison of mscorlib, | |||
/// i.e. for .NET framework 4.5.2, this method return 4.5.2 instead of 4.0.0.0. | |||
/// </remarks> | |||
public static Version GetDotNetFrameworkVersion(Compilation compilation) | |||
public static Version? GetDotNetFrameworkVersion(Compilation compilation) | |||
{ | |||
if (compilation == null || !IsTypeDeclaredInExpectedAssembly(compilation, "System.String", "mscorlib").GetValueOrDefault()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sharwell Do you know why compiler does not generate any warning for parameter not being declared nullable when the code has a null check up front?
src/Microsoft.NetFramework.Analyzers/Core/Helpers/SecurityDiagnosticHelpers.cs
Outdated
Show resolved
Hide resolved
@@ -71,7 +71,7 @@ private static void GetRulesJson(string nugetInstalledPackagesPath, string versi | |||
if (!RoslynString.IsNullOrWhiteSpace(latestRulesJsonPath)) | |||
{ | |||
RuleFileContent latestContent = ReadRuleFileContent(latestRulesJsonPath); | |||
Dictionary<string, RuleInfo> latestRulesById = latestContent.Rules.ToDictionary(r => r.Id); | |||
Dictionary<string?, RuleInfo> latestRulesById = latestContent.Rules.ToDictionary(r => r.Id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm can rule ID be null?
Thank you, @mavasani ! |
Fixes #3069 - XML rules, which I will reimplement with DFA one year.