-
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
Feature Request: Warn the user if they call app.UseGoogleTrace() after app.UseMvc() #1982
Comments
Looking at the |
I wonder if this is something a Roslyn analyzer can help with. I believe you can distribute analyzers with the nuget package (Roslyn itself does this). I can try to look into the feasibility of the analyzer if we want to do something like that. |
@evildour If you don't mind taking a look into this that would be great |
I don't mind at all. This is the fun stuff :) Ok, so I'll re-open this then. |
Perfect, thanks Mike! |
After some prototyping, it seems easy to do the analysis for chained calls, like app.UseMvc();
app.UseGoogleTrace(); Also, it seems relatively easy to get the analyzer used for users of the library: as long as the library includes the analyzer as one of it's own nuget packages (and not a normal reference), anything referencing the Google.Cloud.Diagnostics.AspNetCore library (via nuget or any kind of reference) will have the analyzers run as well. I'm a little ignorant about the problem here and how it might come up. Can you provide a bit more info so I can try to catch as many issues as possible and provide a helpful message?
|
The ordering of these depends on how they are called so for example if we have:
It's calls will end up like this:
Where if we do the opposite we have:
Which leads to:
Responses to your questions:
|
Ok thanks. I have an idea for how to analyze the separate statements approach. It isn't pretty, but might work. I'll try to prototype this later today or next week. As for the code fix provider, these are opt-in: the user has to choose to apply them, so it won't automatically fix intentional code which violates the analyzer's checks. |
I like this feature, but I'd like to point out that using the new |
Sorry @henkmollema, I just saw your comment now. I'll publish the analyzer for now and discuss with @iantalarico about what we can do regarding the new method. Is it equivalent? Would it make sense for the analyzer to simply instruct people to use that instead? |
It is the equivalent of configured Trace, Logging and Error Reporting Middleware. The startup filter makes sure it is configured before any user middleware is added: |
I don't think there's anything to change here. I think if people want to use Do you agree @iantalarico? |
@evildour Yes I agree. I'm sure many people will use |
Agreed 😄 |
If they call
app.UseGoogleTrace()
afterapp.UseMvc()
they'll see no errors and no warnings and no traces, and have no clue why.If there is a way to detect and warn users in this scenario, that would save them a lot of time.
The text was updated successfully, but these errors were encountered: