Skip to content

Add fixer to convert from bound generic types in nameof to unbound types.#75976

Merged
CyrusNajmabadi merged 66 commits intodotnet:mainfrom
CyrusNajmabadi:openTypesFixer
Nov 21, 2024
Merged

Add fixer to convert from bound generic types in nameof to unbound types.#75976
CyrusNajmabadi merged 66 commits intodotnet:mainfrom
CyrusNajmabadi:openTypesFixer

Conversation

@CyrusNajmabadi
Copy link
Contributor

Followup to #75368. Adds an analyzer/fixer to move to the new simpler form.

@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 19, 2024
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review November 19, 2024 22:09
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner November 19, 2024 22:09
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Change to compiler (single file Traits.cs in tests) LGTM Thanks (iteration 59)

var ideDiagnosticIds = typeof(IDEDiagnosticIds).GetFields().Select(f => f.GetValue(f) as string).ToArray();
var unsupportedDiagnosticIds = ideDiagnosticIds.Except(supportedDiagnostics).ToArray();

Assert.Equal(numberOfUnsupportedDiagnosticIds, unsupportedDiagnosticIds.Length);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this part of hte test has never been helpful. and every time we add an analyzer/fixer it fails and all we do is increment those numbers. so i'm deleting.

@CyrusNajmabadi
Copy link
Contributor Author

@ToddGrun ptal.

.Remove(CSharpCodeStyleOptions.PreferredModifierOrder);

AssertEx.SetEqual(optionsWithUI, dataSnapShot.Select(setting => setting.Key.Option));
AssertEx.SetEqual(optionsWithUI.OrderBy(o => o.Name), dataSnapShot.Select(setting => setting.Key.Option).OrderBy(o => o.Name));
Copy link
Contributor

Choose a reason for hiding this comment

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

SetEqual

Why is the ordering necessary for SetEqual?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So that when they differ, the diff you get isn't awful. Basically, the diff function does things linearly, which makes for awful adds/removes/moves :-)


foreach (var typeArgumentList in invocation.DescendantNodesAndSelf().OfType<TypeArgumentListSyntax>())
{
foreach (var argument in typeArgumentList.Arguments)
Copy link
Contributor

Choose a reason for hiding this comment

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

foreach (var argument in typeArgumentList.Arguments)

nit: since argument isn't used except for the filtering, might be nicer to use Any:

if (typeArgumentList.Any(static argument => argument.Kind() != SyntaxKind.OmittedTypeArgument))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha. I'm ok with this.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants