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

Add feature to convert from top-level-statements to Program.Main form #60383

Merged
merged 69 commits into from
Apr 6, 2022

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Mar 25, 2022

Comes with style option: csharp_style_prefer_top_level_statements

Looks like:

image

Todo:

  • Provide way to go from Program.Main to top-level-statements
  • Provide refactoring on top of fixer to go the other direction if the style is there, but set to hidden
  • Have the new-file generation code respect this option if present.

namespace Microsoft.CodeAnalysis.CSharp.ConvertProgram
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ConvertToProgramMain), Shared]
internal class ConvertToProgramMainCodeFixProvider : SyntaxEditorBasedCodeFixProvider
Copy link
Member

Choose a reason for hiding this comment

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

That should be in Analyzers layer.

Copy link
Member Author

Choose a reason for hiding this comment

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

this matches the ConvertNamespace fixer work. we can move both over at the same time if appropriate.

Copy link
Member

Choose a reason for hiding this comment

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

@CyrusNajmabadi This causes bugs like #45569

There are many codefixes that are misplaced in Features. I think it's better if future codefixes are placed properly making the future work to move everything to Analyzers more manageable.

Copy link
Member Author

Choose a reason for hiding this comment

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

so, i'm amenable to that, but i think ti should be done as a general work item that also ensures that the analyzer/fixer layer has all the appropraite other extensions/modules needed to make that work.

CyrusNajmabadi and others added 4 commits March 25, 2022 11:16
Co-authored-by: Youssef Victor <youssefvictor00@gmail.com>
…MainDiagnosticAnalyzer.cs

Co-authored-by: Youssef Victor <youssefvictor00@gmail.com>
@CyrusNajmabadi
Copy link
Member Author

Perhaps a test or two with a file that has a file header, just to make sure that is maintained?

Will do!

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

Successfully merging this pull request may close these issues.

None yet

6 participants