Skip to content
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

Merged
merged 7 commits into from Dec 13, 2019
Merged

Conversation

dotpaul
Copy link
Contributor

@dotpaul dotpaul commented Dec 12, 2019

Fixes #3069 - XML rules, which I will reimplement with DFA one year.

@dotpaul dotpaul requested a review from a team as a code owner December 12, 2019 21:23
@@ -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())
Copy link
Member

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?

@@ -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);
Copy link
Member

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?

@dotpaul
Copy link
Contributor Author

dotpaul commented Dec 13, 2019

Thank you, @mavasani !

@dotpaul dotpaul merged commit d0d013a into dotnet:2.9.x Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants