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

Fix SA1023 for C# 9 function pointer parameters #3252

Merged
merged 4 commits into from
Dec 1, 2020

Conversation

nxtn
Copy link
Contributor

@nxtn nxtn commented Nov 30, 2020

No description provided.

@codecov
Copy link

codecov bot commented Nov 30, 2020

Codecov Report

Merging #3252 (56fa929) into master (aa26bda) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3252   +/-   ##
=======================================
  Coverage   94.39%   94.40%           
=======================================
  Files         967      969    +2     
  Lines      108429   108525   +96     
  Branches     3675     3677    +2     
=======================================
+ Hits       102356   102452   +96     
  Misses       5143     5143           
  Partials      930      930           

@nxtn nxtn marked this pull request as ready for review November 30, 2020 09:31
sharwell
sharwell previously approved these changes Nov 30, 2020
unsafe delegate {|#0:*|}<int*> FuncPtr1;
unsafe delegate{|#1:*|} <int*> FuncPtr2;
unsafe delegate {|#2:*|} managed<int*> FuncPtr3;
unsafe delegate{|#3:*|}managed<int*> FuncPtr4;
Copy link
Member

Choose a reason for hiding this comment

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

💡 IIRC, the unmanaged keyword only works for .NET 5 and newer. I believe there are some instances of tests in the repository using ReferenceAssemblies.Net.Net50 explicitly. Considering function pointers are only officially supported for .NET 5 and newer, it would be fine to just update this test to always use it and test both managed and unmanaged cases. I'm happy to leave this for a follow-up PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well... error CS8889: The target runtime doesn't support extensible or runtime-environment default calling conventions.

Copy link
Member

@sharwell sharwell Nov 30, 2020

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall I specify a calling convention to make the build pass as in #3254?

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer the test be updated to this form instead:

await new CSharpTest(LanguageVersion.CSharp9)
{
ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50,
TestCode = testCode,
ExpectedDiagnostics =
{
// /0/Test0.cs(2,15): warning SA1300: Element 'r' should begin with an uppercase letter
Diagnostic().WithLocation(0).WithArguments("r"),
// /0/Test0.cs(2,15): warning SA1300: Element 'r' should begin with an uppercase letter
Diagnostic().WithLocation(0).WithArguments("r"),
},
FixedCode = fixedCode,
}.RunAsync(CancellationToken.None).ConfigureAwait(false);

@sharwell sharwell merged commit edf811d into DotNetAnalyzers:master Dec 1, 2020
@sharwell
Copy link
Member

sharwell commented Dec 1, 2020

Thanks @NextTurn !

@nxtn nxtn deleted the sa1023 branch December 1, 2020 06:18
@sharwell sharwell added this to the 1.2-beta.next milestone Dec 1, 2020
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.

2 participants