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

Only examine TestCaseAttribute if reference to NUnit exists #41

Merged

Conversation

mikkelbu
Copy link
Member

No description provided.

@mikkelbu mikkelbu merged commit 741196c into nunit:master May 15, 2018
@mikkelbu mikkelbu deleted the return-if-no-TestCaseAttribute-can-be-found branch May 15, 2018 21:19
@@ -49,6 +49,9 @@ private static void AnalyzeAttribute(SyntaxNodeAnalysisContext context)
var attributeSymbol = context.SemanticModel.GetSymbolInfo(attributeNode).Symbol;
var testCaseType = context.SemanticModel.Compilation.GetTypeByMetadataName(NunitFrameworkConstants.FullNameOfTypeTestCaseAttribute);

if (testCaseType == null)
Copy link
Contributor

@JohanLarsson JohanLarsson May 15, 2018

Choose a reason for hiding this comment

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

This can be moved above context.SemanticModel.GetSymbolInfo(attributeNode).Symbol as GetSymbolInfo is a somewhat expensive call. No biggie though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I'll make a subsequent commit. To be honest I have not thought much about performance yet, and I don't have much knowledge about the performance impact of the different methods in Roslyn. My plan was to do some profiling later when we are further in the project.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a rule of thumb we want to check what we can at syntax level before touching symbols. No need to go overboard with it though. In this case it would be pretty weird to have the analyzer installed but no reference to nunit so should be rare.

@mikkelbu mikkelbu restored the return-if-no-TestCaseAttribute-can-be-found branch May 15, 2018 21:35
@mikkelbu mikkelbu added this to the Release 0.2 milestone Apr 13, 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