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

S3655: Static properties and fields called Value #7000

Merged
merged 5 commits into from
Mar 31, 2023

Conversation

antonioaversa
Copy link
Contributor

@antonioaversa antonioaversa commented Mar 28, 2023

Part 6 of task 6 of #6794

Previous task: #6996

Fixes #6794

Fixes NullReferenceException issues encountered on peach, such as:

CSC : error AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.SymbolicExecutionRunner' threw an exception of type 'SonarAnalyzer.SymbolicExecution.SymbolicExecutionException' with message '
Error processing method: .ctor ## Method file: C:\Project\src\System.Private.ServiceModel\src\Internals\System\Runtime\IOThreadTimer.cs ## 
Method line: 55,8 ## Inner exception: System.NullReferenceException: Object reference not set to an instance of an object. ##    
at SonarAnalyzer.SymbolicExecution.Roslyn.RuleChecks.EmptyNullableValueAccessBase.PreProcessSimple(SymbolicContext context) ##    
at SonarAnalyzer.SymbolicExecution.Roslyn.SymbolicCheck.PreProcess(SymbolicContext context) ##    
at SonarAnalyzer.SymbolicExecution.Roslyn.SymbolicCheckList.InvokeChecks(SymbolicContext context, Boolean preProcess) ##    
at SonarAnalyzer.SymbolicExecution.Roslyn.RoslynSymbolicExecution.ProcessOperation(ExplodedNode node)+MoveNext() ##    
at SonarAnalyzer.SymbolicExecution.Roslyn.RoslynSymbolicExecution.Execute() ##    
at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.AnalyzeRoslyn(SonarAnalysisContext analysisContext, SonarSyntaxNodeReportingContext nodeContext, SyntaxNode body, ISymbol symbol)'. [C:\Project\src\System.Private.ServiceModel\src\System.Private.ServiceModel.csproj]

@github-actions github-actions bot added this to In progress in Best Kanban Mar 28, 2023
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-6 branch from 79b9328 to b3538ce Compare March 28, 2023 14:26
@antonioaversa antonioaversa changed the title S3655: Static properties named Value S3655: Static properties and fields named Value Mar 28, 2023
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-6 branch 2 times, most recently from 6da4d84 to a24b41c Compare March 28, 2023 15:12
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-5 branch from 5c31e36 to eb18c34 Compare March 29, 2023 07:17
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-6 branch from a24b41c to 4cf35c7 Compare March 29, 2023 13:39
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Mar 29, 2023
@antonioaversa antonioaversa linked an issue Mar 29, 2023 that may be closed by this pull request
6 tasks
Comment on lines 988 to 1019
class AClassWithStaticValueProperty
{
public AClassWithInstanceValueProperty InstanceProperty => new AClassWithInstanceValueProperty();

public static AClassWithInstanceValueProperty Value => new AClassWithInstanceValueProperty();
}

class AClassWithInstanceValueProperty
{
public AClassWithStaticValueProperty Value => new AClassWithStaticValueProperty();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not value properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your definition of "value property"? It's a property, and it's named Value, so I named it ValueProperty.

Would you prefer PropertyNamedValue instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this makes more sense. I was thinking of value types. I'd go with ClassWithStaticPropertyCalledValue to avoid confusion.

Comment on lines 1015 to 1046
class AClassWithStaticValueField
{
public AClassWithInstanceValueField InstanceField = new AClassWithInstanceValueField();

public static AClassWithInstanceValueField Value = new AClassWithInstanceValueField();
}

class AClassWithInstanceValueField
{
public AClassWithStaticValueField Value = new AClassWithStaticValueField();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not value fields.

Copy link
Contributor Author

@antonioaversa antonioaversa Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #7000 (comment), I'd say.

@pavel-mikula-sonarsource pavel-mikula-sonarsource removed this from Review in progress in Best Kanban Mar 30, 2023
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-5 branch from b5ba602 to 9480d62 Compare March 30, 2023 06:55
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-6 branch from 4cf35c7 to 008e632 Compare March 30, 2023 06:55
@github-actions github-actions bot added this to Review in progress in Best Kanban Mar 30, 2023
Copy link
Contributor

@Tim-Pohlmann Tim-Pohlmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments above.

@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban Mar 30, 2023
@antonioaversa antonioaversa changed the title S3655: Static properties and fields named Value S3655: Static properties and fields called Value Mar 30, 2023
@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Mar 30, 2023
@pavel-mikula-sonarsource pavel-mikula-sonarsource removed this from Review approved in Best Kanban Mar 30, 2023
Base automatically changed from Antonio/S3655-cs9-cs10-syntax-step6-5 to feature/SE March 30, 2023 11:55
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-6 branch from c9ab91c to 32b0d1e Compare March 30, 2023 11:59
@antonioaversa antonioaversa marked this pull request as ready for review March 30, 2023 12:03
@github-actions github-actions bot added this to Review in progress in Best Kanban Mar 30, 2023
Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some minor polishing

@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Mar 30, 2023
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-6 branch from 8856033 to 74ea7d5 Compare March 31, 2023 11:47
@antonioaversa antonioaversa force-pushed the Antonio/S3655-cs9-cs10-syntax-step6-6 branch from 74ea7d5 to 2dea496 Compare March 31, 2023 12:07
@sonarcloud
Copy link

sonarcloud bot commented Mar 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Mar 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@antonioaversa antonioaversa merged commit 12c8b40 into feature/SE Mar 31, 2023
Best Kanban automation moved this from Review approved to Validate Peach Mar 31, 2023
@antonioaversa antonioaversa deleted the Antonio/S3655-cs9-cs10-syntax-step6-6 branch March 31, 2023 12:27
@antonioaversa antonioaversa moved this from Validate Peach to Done in Best Kanban Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Best Kanban
  
Done
Development

Successfully merging this pull request may close these issues.

Improve S3655: Support C# 9 and C# 10 syntax
3 participants