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

Write DiagnosticSuppressor for CS8618 #21618

Closed
wants to merge 1 commit into from

Conversation

Youssef1313
Copy link
Member

Fixes #21608

This is not ready yet. I need some guidance on writing the unit test, as well as reviewing the suppressor and guidance on the TODO comment.

cc: @ajcvickers @roji


namespace Microsoft.EntityFrameworkCore
{
public class NullabilityDiagnosticSuppressorTest
Copy link
Member

Choose a reason for hiding this comment

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

I recommend you take a look at InternalUsageDiagnosticAnalyzerTest and try to do something similar.

Copy link
Member Author

Choose a reason for hiding this comment

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

@roji I tried to do that. But seems like the current BaseTest won't fit well with testing suppressor.

Copy link
Member

Choose a reason for hiding this comment

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

In that case I'd look at some other well-known suppressor and try to see what it does..

Copy link
Member

@sharwell sharwell Jul 17, 2020

Choose a reason for hiding this comment

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

We don't have a good way to test suppressors currently. We're still looking into options.

continue;
}

// TODO: Check if the class derives from DbContext. (Not sure how to do it yet)
Copy link
Member

Choose a reason for hiding this comment

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

The code as is only looking at syntax nodes, which isn't sufficient for identifying inheritance AFAIK - you need to look at the semantic model (GetSymbolInfo). However, GetSymbolInfo apparently has some perf issues, so #18637 is about modifying our current analyzer to use IOperation instead; am not sure exactly how that looks like for a suppressor but it should be possible.

At least for now, our analyzers package does cannot reference EF Core types directly (I'll try to see about improving this in the future), so you can only identify/recognize EF types by name.

Copy link
Member Author

Choose a reason for hiding this comment

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

@roji, I'll try to play around with SemanticModel.

Copy link
Member

Choose a reason for hiding this comment

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

@Youssef1313 please hold off on this, @davidroth's suggestion in #21608 will likely obviate this.

@roji roji marked this pull request as draft July 15, 2020 13:04
@roji
Copy link
Member

roji commented Jul 18, 2020

@Youssef1313 am closing this as @davidroth's suggestion to simply initialize the DbSet properties is cleaner and obviates this - but thanks for your work on this.

There's still #21663 which could definitely benefit from a suppressor, but please note it's unlikely we'll merge this for 5.0 this late.

@roji roji closed this Jul 18, 2020
@Youssef1313 Youssef1313 deleted the suppression branch July 18, 2020 15:30
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.

Write a DiagnosticSuppressor for CS8618 for DbSet properties
3 participants