Skip to content

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

Merged
michaelnebel merged 1 commit intogithub:mainfrom
michaelnebel:csharp/refactorimports
Aug 22, 2023
Merged

C#: Re-factor order of usings.#13995
michaelnebel merged 1 commit intogithub:mainfrom
michaelnebel:csharp/refactorimports

Conversation

@michaelnebel
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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