Skip to content

C#: Re-factor order of usings. #13995

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

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

michaelnebel
Copy link
Contributor

In this PR we introduce the following standard for using statements in our C# extractor source code files.
The order is

  • System* (the standard library).
  • Third party libraries (eg. Microsoft.CodeAnalysis).
  • Semmle* (out own namespaces), starting with Semmle.Util* (the remaining is in alphabetical order)
  • Type abbreviations (using X = Y).

Unit test projects follows the same pattern except that the first using statement is using Xunit.

@github-actions github-actions bot added the C# label Aug 18, 2023
@michaelnebel michaelnebel force-pushed the csharp/refactorimports branch 2 times, most recently from ee2944d to dd5a9fd Compare August 21, 2023 07:26
@michaelnebel michaelnebel force-pushed the csharp/refactorimports branch from dd5a9fd to 864f60f Compare August 21, 2023 07:41
@michaelnebel michaelnebel added the no-change-note-required This PR does not need a change note label Aug 21, 2023
@michaelnebel michaelnebel marked this pull request as ready for review August 21, 2023 08:31
@michaelnebel michaelnebel requested a review from a team as a code owner August 21, 2023 08:31
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Is there a VS code plugin to enforce this?

@michaelnebel
Copy link
Contributor Author

Is there a VS code plugin to enforce this?

That is a really good question (I didn't use any when doing the rearrangement)!
I found C# Format Usings which helps quite a lot (using the following sort order: Xunit System Microsoft Semmle.Util Semmle). It requires that you execute Format Usings on the file where you want re-format.

@michaelnebel
Copy link
Contributor Author

@hvitved : Added the C# Format Usings as recommended plugin: #14015

@michaelnebel michaelnebel changed the title C#: Re-factor imports. C#: Re-factor order of usings. Aug 22, 2023
@michaelnebel michaelnebel merged commit 2b718fb into github:main Aug 22, 2023
@michaelnebel michaelnebel deleted the csharp/refactorimports branch August 22, 2023 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants