-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Check modifiers on record positional members #45898
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
Conversation
src/Compilers/CSharp/Portable/Symbols/Source/SourceConstructorSymbolBase.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordConstructor.cs
Outdated
Show resolved
Hide resolved
| } | ||
| } | ||
|
|
||
| public sealed override bool IsImplicitlyDeclared |
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.
public sealed override bool IsImplicitlyDeclared [](start = 8, length = 48)
It looks like this change is unnecessary, given the comment in SynthesizedRecordConstructor.cs. #Closed
|
Done with review pass (iteration 2) #Closed |
| { | ||
| // we don't analyze synthesized void methods. | ||
| if ((method.IsImplicitlyDeclared && !method.IsScriptInitializer) || | ||
| if ((method.IsImplicitlyDeclared && !method.IsScriptInitializer) || method is SynthesizedRecordConstructor || |
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.
📝 This is primarily to avoid cascading diagnostics (illustrated below), but also seems reasonable (why do extra analysis work on synthesized methods which we fully control?).
[Fact, WorkItem(45008, "[https://github.com/dotnet/roslyn/issues/45008](https://github.com/dotnet/roslyn/issues/45008)")]
public void PositionalMemberModifiers_RefOrOut()
{
var src = @"
record R(ref int P1, out int P2);
";
var comp = CreateCompilation(src);
comp.VerifyDiagnostics(
// (2,9): error CS0177: The out parameter 'P2' must be assigned to before control leaves the current method
// record R(ref int P1, out int P2);
Diagnostic(ErrorCode.ERR_ParamUnassigned, "(ref int P1, out int P2)").WithArguments("P2").WithLocation(2, 9),
// (2,10): error CS0631: ref and out are not valid in this context
// record R(ref int P1, out int P2);
Diagnostic(ErrorCode.ERR_IllegalRefParam, "ref").WithLocation(2, 10),
// (2,22): error CS0631: ref and out are not valid in this context
// record R(ref int P1, out int P2);
Diagnostic(ErrorCode.ERR_IllegalRefParam, "out").WithLocation(2, 22)
);
}
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.
why do extra analysis work on synthesized methods which we fully control?
We are not fully in control, there is user code in this method. Please revert this change. If you want to suppress specific diagnostics, suppress that specific diagnostics instead. It will be more robust to avoid making suppressions like that across the board. I personally, don't even think the diagnostics is cascading or should be suppressed, it reflects exactly what is happening, the parameter could be assigned in any of the initializers, or in base arguments.
In reply to: 454571864 [](ancestors = 454571864)
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.
We might even come up with a scenario where the analysis produces useful diagnostics about code in initializers, or in base arguments.
In reply to: 455167934 [](ancestors = 455167934,454571864)
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.
Thanks. I understand now. We definitely want to analyze the base call.
src/Test/Utilities/Portable/Diagnostics/DiagnosticExtensions.cs
Outdated
Show resolved
Hide resolved
|
Done with review pass (iteration 5) #Closed |
AlekseyTs
left a comment
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 (iteration 6), assuming CI is passing.
* upstream/master: (86 commits) Better client / server logging (dotnet#46079) Fix OptProf config Update src/VisualStudio/LiveShare/Impl/AbstractGoToDefinitionWithFindUsagesServiceHandler.cs Do not execute RemoveUnnecessaryInlineSuppressions on generated code Update dependencies from https://github.com/dotnet/arcade build 20200715.6 (dotnet#46086) Use ISpanMapper before sending cross file results to LSP Add additional module initializers tests from review (dotnet#46020) Fix type in OptProf configuration bump to 500 Fixed VS crash during implicit conversion of null object in nullable walker (dotnet#45974) Rename variable Fix KeyNotFound exception in RemoveUnnecessaryInlineSuppressionsDiagnosticAnalyzer Check modifiers on record positional members (dotnet#45898) Fix typos and link in Source Generators cookbook (dotnet#44372) Remove reference to non-existing VisualStudioInteractiveComponents.vsix from deployment VSIX. (dotnet#45979) Address feedback + fix tests Update dependencies from https://github.com/dotnet/roslyn build 20200711.1 (dotnet#45932) Make MetadataTypeName non-copyable Fix usage of GetService extension Consolidate service provider extensions ...
…to function-pointer-type-lookup * upstream/features/function-pointers: (86 commits) Better client / server logging (dotnet#46079) Fix OptProf config Update src/VisualStudio/LiveShare/Impl/AbstractGoToDefinitionWithFindUsagesServiceHandler.cs Do not execute RemoveUnnecessaryInlineSuppressions on generated code Update dependencies from https://github.com/dotnet/arcade build 20200715.6 (dotnet#46086) Use ISpanMapper before sending cross file results to LSP Add additional module initializers tests from review (dotnet#46020) Fix type in OptProf configuration bump to 500 Fixed VS crash during implicit conversion of null object in nullable walker (dotnet#45974) Rename variable Fix KeyNotFound exception in RemoveUnnecessaryInlineSuppressionsDiagnosticAnalyzer Check modifiers on record positional members (dotnet#45898) Fix typos and link in Source Generators cookbook (dotnet#44372) Remove reference to non-existing VisualStudioInteractiveComponents.vsix from deployment VSIX. (dotnet#45979) Address feedback + fix tests Update dependencies from https://github.com/dotnet/roslyn build 20200711.1 (dotnet#45932) Make MetadataTypeName non-copyable Fix usage of GetService extension Consolidate service provider extensions ...
Fixes #45008
Corresponding spec update: dotnet/csharplang#3672