-
Notifications
You must be signed in to change notification settings - Fork 231
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
Implement S6562: Always set the DateTimeKind when creating a new DateTime object #7527
The head ref may contain hidden characters: "\u010Daba/S6562"
Conversation
26fcd62
to
9485f2d
Compare
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.
Review round 1
analyzers/src/SonarAnalyzer.Common/Rules/AlwaysSetDateTimeKindBase.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/AlwaysSetDateTimeKind.vb
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/AlwaysSetDateTimeKind.cs
Show resolved
Hide resolved
public void AlwaysSetDateTimeKind_VB() => | ||
new VerifierBuilder<VB.AlwaysSetDateTimeKind>().AddPaths("AlwaysSetDateTimeKind.vb").Verify(); | ||
|
||
#if NET |
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.
No need for #if NET
. The test code under AlwaysSetDateTimeKind_CSharp9
works under the .NET Framework as well.
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.
Since C#9 is not supported in .Net Framework. We opted to run all C#9+ test cases only for .NET core
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.
C# 9 (and even newer language versions) are supported in .NET Framework. Not every language feature is available, but implicit object creations are, so I see no reasons why we should leave it out.
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/AlwaysSetDateTimeKind.cs
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/AlwaysSetDateTimeKind.cs
Outdated
Show resolved
Hide resolved
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.
Looks good, I left a few suggestions
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.
LGTM
public void AlwaysSetDateTimeKind_VB() => | ||
new VerifierBuilder<VB.AlwaysSetDateTimeKind>().AddPaths("AlwaysSetDateTimeKind.vb").Verify(); | ||
|
||
#if NET |
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.
C# 9 (and even newer language versions) are supported in .NET Framework. Not every language feature is available, but implicit object creations are, so I see no reasons why we should leave it out.
analyzers/src/SonarAnalyzer.CSharp/Rules/AlwaysSetDateTimeKind.cs
Outdated
Show resolved
Hide resolved
…t for .NET framework
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
Fixes #7081