-
Notifications
You must be signed in to change notification settings - Fork 368
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
Add analyzer to warn about wrong UseGoogleTrace/UseMvc order #2054
Conversation
I'm fine for us to mix and match between internal and public, so long as everything is still unique - I don't think users will attach particular meaning. I probably won't be able to review this until Tuesday, but I'll ask friends in the Roslyn team to have a look in terms of packaging. |
Great, thanks! |
Travis failure looks like it may be this: dotnet/msbuild#1957. There is a workaround here: dotnet/msbuild#1957 (comment), which I'll try. |
Codecov Report
@@ Coverage Diff @@
## master #2054 +/- ##
==========================================
- Coverage 55.85% 27.96% -27.9%
==========================================
Files 516 58 -458
Lines 15673 937 -14736
==========================================
- Hits 8754 262 -8492
+ Misses 6919 675 -6244
Continue to review full report at Codecov.
|
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.
Just a first pass, I need to read up a little on some of this and will take another pass at it.
This is pretty cool, thanks for doing this Mike!
Not sure if it's worth doing here or in another PR but we should probably do the same for error reporting bits.
@@ -0,0 +1,58 @@ | |||
param($installPath, $toolsPath, $package, $project) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -0,0 +1,58 @@ | |||
param($installPath, $toolsPath, $package, $project) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -0,0 +1,58 @@ | |||
param($installPath, $toolsPath, $package, $project) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -0,0 +1,58 @@ | |||
param($installPath, $toolsPath, $package, $project) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
catch | ||
{ | ||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -93,7 +93,8 @@ public class MissingCopyrightNoticeAnalyzer : DiagnosticAnalyzer | |||
"//------------------------------------------------------------------------------\n// <auto-generated>", | |||
"//------------------------------------------------------------------------------\r\n// <auto-generated>", | |||
"// Generated by the protocol buffer compiler. DO NOT EDIT!", | |||
"// Generated by the MSBuild WriteCodeFragment class."); | |||
"// Generated by the MSBuild WriteCodeFragment class.", | |||
"// This file was automatically created from"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
var analyzersDirectory = Path.Combine(apiRoot, api.Id + ".Analyzers"); | ||
if (!Directory.Exists(analyzersDirectory)) | ||
{ | ||
Directory.CreateDirectory(analyzersDirectory); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
AddPackFile( | ||
$@"..\{api.Id}.Analyzers\bin\$(Configuration)\{AnalyzersTargetFramework}\{api.Id}.Analyzers.dll", | ||
"analyzers/dotnet/cs"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
base.FinalizeSolution(projectId, ref solution); | ||
} | ||
} | ||
} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
private const string UseGoogleTrace = "UseGoogleTrace"; | ||
private const string UseMvc = "UseMvc"; | ||
|
||
private static readonly LocalizableString Title = |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
What need's to be done for the error reporting bits? Is it the same concept of an ordering requirement? |
@evildour Yea it's pretty much the same thing it needs to be called before things you want uncaught exceptions logged for MVC is probably where the bulk of this would be. |
@evildour Hit enter too soon. It's probably worth doing error reporting in a separate PR as this is already fairly large. |
Yeah I agree. I'd like to nail down the packaging strategy first so we can get this in. Then I'll generalize it in another PR. |
998f356
to
e33a684
Compare
Ok now the analyzers will be their own package. PTAL. |
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.
I reviewed the tests more than the implementation, but it looks okay. Is there anything specific you want me to pay more attention to?
{ | ||
public class GoogleTraceBeforeMvcAnalyzerTests : CodeFixVerifier | ||
{ | ||
private static readonly MetadataReference RuntimeReference = |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
|
||
[Fact] | ||
public void SeparateChecksInSeaprateScopes() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
{ | ||
internal static ITypeSymbol Type(this ISymbol symbol) | ||
{ | ||
switch (symbol.Kind) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I guess just the package details because I think we should publish these analyzers after this PR is merged. Note: I realized I forgot to actually look in the package to make sure things were correct before, and they weren't, so I also made a few fixes there. PTAL at the project generator. |
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.
Changes seem reasonable. That said, the project generator is definitely growing in a somewhat Vogon-like way... we may want to take a step back and see if the current requirements could be better implemented with an overhaul. I'm slightly surprised we've managed to bend it this far :)
Yeah, that might be a good idea, but in a different PR. Are you ok if I publish this right after merging? @iantalarico are you still taking a look here or are you good? |
c1172dd
to
c6a3151
Compare
(rebase) |
Resolves #1982
Recommend to review one commit at a time.
cc @SurferJeffAtGoogle