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 unspeakable main name #4256

Merged
merged 1 commit into from
Sep 30, 2020
Merged

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Sep 30, 2020

Related to #4253 (keeping the issue open to track using the compiler API)

@Youssef1313 Youssef1313 requested a review from a team as a code owner September 30, 2020 17:30
eng/Versions.props Outdated Show resolved Hide resolved
Copy link
Contributor

@mavasani mavasani left a comment

Choose a reason for hiding this comment

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

As commented. Just upgrading to this constant API does not warrant bumping up the code analysis version for the entire repo.

methodSymbol.Name switch
{
"$Main" => true,
"<$Main>$" => true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@mavasani When the code in tests is compiled, it's compiled against an older compiler version that produces $Main instead of <Main>$. I wanted to remove the old name from the extension method, so that required a newer version of the compiler. But as this is causing problems, I'll revert.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you want to keep the issue open to track using the compiler API when it's good time to update the version?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you need new bits only for test you can bump up the below:

<MicrosoftCodeAnalysisForShippedApisVersion>3.7.0</MicrosoftCodeAnalysisForShippedApisVersion>

We should probably rename that property name to suggest that is for tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to keep the issue open to track using the compiler API when it's good time to update the version?

That sounds reasonable. Thanks.

=> typeSymbol?.IsStatic == true && typeSymbol.Name switch
{
"$Program" => true,
"<Program>$" => true,
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be just fine.

Copy link
Contributor

@mavasani mavasani left a comment

Choose a reason for hiding this comment

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

Seems like this needs a single char deletion fix :-)

@codecov
Copy link

codecov bot commented Sep 30, 2020

Codecov Report

Merging #4256 into master will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #4256      +/-   ##
==========================================
- Coverage   95.80%   95.80%   -0.01%     
==========================================
  Files        1170     1168       -2     
  Lines      264526   264635     +109     
  Branches    15962    15964       +2     
==========================================
+ Hits       253428   253525      +97     
- Misses       9085     9096      +11     
- Partials     2013     2014       +1     

"<$Main>$" => true,
_ => false
};
methodSymbol.IsStatic && methodSymbol.Name == "<Main>$";
Copy link
Contributor

Choose a reason for hiding this comment

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

Please retain the old logic as "$Main" was used in older compiler bits which is supported by the analyzer package. I think you should only fix the typo here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought that's not important as the compiler version has this isn't a stable release. I'll revert the last 2 commits.

Copy link
Contributor

Choose a reason for hiding this comment

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

as the compiler version has this isn't a stable release

Ah, if you are sure it wasn't a stable release, then it would be fine to remove those cases. By the way, there are test failures.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, if you are sure it wasn't a stable release, then it would be fine to remove those cases

@mavasani I think it was shipped only in a preview version of Visual Studio. But might be better to confirm with the compiler team. Not sure who may be able help.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mavasani The current test failures seems unrelated to top-level statements. Can you have a look?

For example:

public async Task CSharp_CA1063_FinalizeOverride_Diagnostic_DoubleFinalizeOverride_InvokesDisposeBool()
{
await VerifyCS.VerifyAnalyzerAsync(@"
using System;
public class A : IDisposable
{
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~A()
{
Dispose(false);
}
protected virtual void Dispose(bool disposing)
{
}
}
public class B : A
{
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
~B()
{
Dispose(false);
}
}
public class C : B
{
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}
~C()
{
Dispose(false);
}
}
",
// Test0.cs(22,14): warning CA1063: Remove the finalizer from type 'B', override Dispose(bool disposing), and put the finalization logic in the code path where 'disposing' is false. Otherwise, it might lead to duplicate Dispose invocations as the Base type 'A' also provides a finalizer.
GetCA1063CSharpFinalizeOverrideResultAt(22, 14, "B", "A"),
// Test0.cs(35,14): warning CA1063: Remove the finalizer from type 'C', override Dispose(bool disposing), and put the finalization logic in the code path where 'disposing' is false. Otherwise, it might lead to duplicate Dispose invocations as the Base type 'B' also provides a finalizer.
GetCA1063CSharpFinalizeOverrideResultAt(35, 14, "C", "B"));
}

This test doesn't produce any diagnostics, while 2 are expected. The number of failing tests is huge.

@Evangelink
Copy link
Member

@Youssef1313 I am having some trouble understanding the link between the name of the PR and its content. What am I missing?

@Youssef1313
Copy link
Member Author

@Youssef1313 I am having some trouble understanding the link between the name of the PR and its content. What am I missing?

Did you mean the "unspeakable" part of the title? That's what the compiler team calls these generated members names.

@Evangelink
Copy link
Member

@Youssef1313 I am having some trouble understanding the link between the name of the PR and its content. What am I missing?

Did you mean the "unspeakable" part of the title? That's what the compiler team calls these generated members names.

Oh I see, thanks :)

@Youssef1313
Copy link
Member Author

Youssef1313 commented Sep 30, 2020

Given these test failures here (whose reason is known for me - I may investigate later), I won't update the version to use the compiler API and just fix the typo.

@mavasani mavasani merged commit 939a3c8 into dotnet:master Sep 30, 2020
@Youssef1313 Youssef1313 deleted the fix-top-level-names branch September 30, 2020 21:24
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.

3 participants