-
Notifications
You must be signed in to change notification settings - Fork 506
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
Implemented SA1121 #350
Implemented SA1121 #350
Conversation
Now that #306 is merged, can you rebase this and reduce it to a nice set of tests (plus enabling the diagnostic)? 👍 If you aren't comfortable with Git rebase, you can also do a pull from the |
This should bring in the tests. Im working on the code fix |
{ | ||
static readonly Tuple<string, string>[] _referenceTypes = new Tuple<string, string>[] | ||
{ | ||
new Tuple<string,string>("object", "Object"), |
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.
nameof(Object)
for the right hand side here. 😉 The same for the items below.
Can you add this test? namespace Foo
{
using Int32 = System.UInt32;
class Bar
{
Int32 value = 3;
}
} A diagnostic should be reported, but the target built-in type is actually |
Also can you add this test? namespace Foo
{
using MyInt = System.Int32;
class Bar
{
MyInt value = 3;
}
} |
What are the desired results here? Should using Int32 = System.UInt32; change to using Int32 = uint; or should the Int32 value = 3; change to uint value = 3; ? Or both? Currently it will report 2 diagnostics at MyInt value = 3; and the code fix im implementing is replacing it there |
|
These new tests have some issues. The diagnostic analyzer is called twice for the same IdentifierToken. Do you know why this might happen? |
new DiagnosticResultLocation("Test0.cs", 6, 5) | ||
} | ||
}, | ||
// Workaround because the diagnostic is called twice for the SyntaxNode |
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 could not figure out why this happens. Maybe a roslyn bug?
It's a bug somewhere in the unit test framework for this extension (modified from the one in the Roslyn templates). The diagnostics are only reported once for actual code, so I merged this and created an issue to find the bug in the unit test framework. |
Fixes #54. Unfortunatly the diagnostic itself was already implemented in #306. But this one contains a bunch of unit tests so it might be a good idea to use them