-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Sorting usings #923
Sorting usings #923
Changes from 15 commits
de96c75
3383f7a
0e9b796
bbd53b0
2f63d8b
5f013d8
f21bbad
d7241bf
29527c1
54d9889
9208e24
fc75190
ecea472
45b9d68
17eb944
c7d7165
6802f6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
function CSH-Release { | ||
function CSH-CreateRelease { | ||
param ( | ||
[Parameter(Mandatory=$true)] | ||
[string]$versionNumber | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function CSH-DeleteReviewBranches { | ||
|
||
# TODO probably make this configurable | ||
$pathToTestingRepo = "C:/Projects/csharpier-repos" | ||
Set-Location $pathToTestingRepo | ||
|
||
git checkout main | ||
git branch | Where-Object { $_ -notmatch "main" } | ForEach-Object { git branch -D $_ } | ||
git branch -r | Where-Object { $_ -notmatch "origin/main" } | ForEach-Object { git push origin --delete $_.Replace("origin/", "").Trim() } | ||
} | ||
|
||
Export-ModuleMember -Function CSH-* |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
// leading | ||
using First; // trailing | ||
|
||
using A; // trailing | ||
// leading with space | ||
using // another trailing | ||
Second; | ||
|
||
using | ||
// static leading | ||
static // static trailing | ||
Third; | ||
|
||
using M = System.Math; | ||
using Point = (int x, int y); | ||
|
||
using static System.Math; | ||
|
||
global using System; | ||
|
||
using First; | ||
using Second; | ||
B; | ||
|
||
namespace Namespace | ||
{ | ||
using Third; | ||
using One.Two.Three; | ||
using Third; | ||
|
||
public class ClassName { } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using System; | ||
#if DEBUG | ||
using Insite.Bad; | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#if DEBUG | ||
using Insite.Bad; | ||
#endif | ||
using System; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using AWord; | ||
using BWord; | ||
using MWord; | ||
using YWord; | ||
using ZWord; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
using MWord; | ||
using ZWord; | ||
using AWord; | ||
using BWord; | ||
using YWord; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
global using Global; | ||
using System; | ||
using global::Zebra; | ||
using Custom; | ||
using static Expression; | ||
using Point = (int x, int y); | ||
using Index = Microsoft.Framework.Index; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#if BUILD_MSI_TASKS | ||
using System; | ||
using Microsoft.Build.Framework; | ||
|
||
namespace RepoTasks; | ||
|
||
class ClassName { } | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.IO; | ||
#if DEBUG | ||
using System; | ||
#else | ||
using Microsoft; | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if DEBUG | ||
using System; | ||
#else | ||
using Microsoft; | ||
#endif | ||
using System.IO; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.IO; | ||
#if !DEBUG | ||
using System; | ||
#else | ||
using Microsoft; | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if !DEBUG | ||
using System; | ||
#else | ||
using Microsoft; | ||
#endif | ||
using System.IO; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#if DEBUG | ||
using A; | ||
#else | ||
using B; | ||
#endif | ||
#if !DEBUG | ||
using C; | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using C; | ||
#if DEBUG | ||
using A; | ||
#else | ||
using B; | ||
#endif | ||
|
||
#if !DEBUG | ||
using C; | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#if DEBUG | ||
using A; | ||
#else | ||
using B; | ||
#endif | ||
using C; | ||
#if !DEBUG | ||
using C; | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if DEBUG | ||
#define SYMBOL | ||
#endif | ||
|
||
using System; | ||
using System.Collections; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if DEBUG | ||
#define SYMBOL | ||
#endif | ||
|
||
using System.Collections; | ||
using System; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#if DEBUG | ||
extern alias MonoSecurity; | ||
#else | ||
using Mono.Security.Cryptography; | ||
#endif | ||
|
||
using System; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#if DEBUG | ||
extern alias MonoSecurity; | ||
#else | ||
using Mono.Security.Cryptography; | ||
#endif | ||
|
||
using System; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if XMLCHARTYPE_GEN_RESOURCE | ||
#undef XMLCHARTYPE_USE_RESOURCE | ||
#endif | ||
|
||
using System.Diagnostics; | ||
using System.Threading; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if XMLCHARTYPE_GEN_RESOURCE | ||
#undef XMLCHARTYPE_USE_RESOURCE | ||
#endif | ||
|
||
using System.Threading; | ||
using System.Diagnostics; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Licensed to something | ||
|
||
using Apple; | ||
using Microsoft; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there should be some test cases for code that does crazy things with comments, for example: // Licensed to something
using Microsoft.AspNetCore;
// I like putting
using Microsoft;
/*
* random comments everywhere
*/
using Apple;
/* because it's valid C# code */
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
// Look mom, I'm using a really fancy authentication library:
using Microsoft.Identity.Web.UI;
using Microsoft.Identity.Web; // another comment just for good measure I'm unsure how this case should be handled, these are the options I could think of:
As far as I can tell tell it's impossible to sort usings with comments while preserving the original intent of the comments in all cases. I don't really care what the final solution is, just that it's tested and works with all the possible comment formats. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping comments at the top was the only tricky part. Most comments are leading trivia which just goes with the node it is above. Trailing comments also stick with the node they are after. From all the code I reviewed, comments in usings aren't that common.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Licensed to something | ||
|
||
using Microsoft; | ||
using Apple; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// | ||
|
||
#define USE_STRUCT | ||
using System; | ||
using System.Runtime.CompilerServices; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// | ||
|
||
#define USE_STRUCT | ||
using System.Runtime.CompilerServices; | ||
using System; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// | ||
|
||
#undef USE_STRUCT | ||
using System; | ||
using System.Runtime.CompilerServices; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// | ||
|
||
#undef USE_STRUCT | ||
using System.Runtime.CompilerServices; | ||
using System; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
using A = Z; | ||
using M = A; | ||
using Z = M; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using System; | ||
using System.Web; | ||
using AWord; | ||
using ZWord; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
using ZWord; | ||
using AWord; | ||
using System.Web; | ||
using System; |
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.
wtf is this?
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 believe that was me going nuts trying comments everywhere a while back.
Apparently that is valid c#!