-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Precursor to share code with RoslynAnalyzers. #79117
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
Changes from all commits
9af286b
f1e7a67
0b25d8d
48053b1
0daf95e
1beb198
cfd26fe
abfbfc6
6c62edb
3e08ace
c632cbf
cb32937
d316719
5b2ba52
c4c76e6
14d1d34
0f687ed
bd8e197
8f95b97
ca6c7ea
0f0e1fd
c7a66e6
d6c47d6
edc3056
d42b32c
bc57bf3
4479abd
f3f0442
ccbeb97
fdb858d
54e0735
6bf5753
1fad1eb
7b4e97b
43975af
08ec8e6
8b2a9a4
aa89456
0850355
639fcc2
4a43994
8649c1e
972293e
5f324c3
f6c93b1
7eeac7f
3aa33fe
7e45300
af4cd51
ac51485
ec933f0
c982a28
bab0aeb
73bfe32
dee647c
79ea2b9
49a66a6
95ab927
34271f5
3bc4d11
cf40bb8
20e3731
7736f9e
f2424d7
b4c710a
c130701
b593ca6
e1b122f
af06be7
4263a20
be1d8cb
318d135
80ae2c8
e89f3dc
ee0f2e6
6f7c1dd
7023502
23e2fe0
23d0dc2
75802b8
7bdb068
c626a61
da0a4e1
9fafb2f
515d60b
77a0268
a660e8c
8ecc6f5
17d4a07
dc01cc1
c8a20ad
5f94abc
67a1018
ccb3bdb
d0738f3
52999a2
0178009
65b132a
e4d38c8
0fb4cb8
55d0888
a637896
589ddf7
400c917
43f65f1
79e51eb
43b0fa1
f8e0686
b5692f8
32a5793
7483f30
405b044
5d15453
d2c8d22
a1568fe
f2e5b36
ebb062e
e72aca4
d615d79
c40cb81
474fd9c
d94ea42
a182e50
43eb81c
7867663
0366273
cc1ab83
bb13144
7c002cb
4c1e728
9088af2
ac66ad2
88a6ad6
6faf157
c9fa791
b895a41
e084354
9f88734
b127c75
3463739
b97ebd8
befa388
e04f437
51eadaf
780a170
3fec28c
11834f3
4fdedae
897d88a
26f6c3f
4fe56aa
7b1712a
7d7a41c
57aa92d
5ee7bed
ab88418
437356b
b47b2f4
4cf9c07
3fdb0dc
d98d813
54c70ac
35529fa
32678bc
1970f07
130545b
896230d
6997c9b
4de5c99
cddde18
b4e6491
afe4291
c3bd2f9
13d651e
e857048
e326309
0a46715
d3f910e
22e9ee8
517c2ae
d265a77
c0a01b4
a137049
6274d80
e12421c
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 |
|---|---|---|
|
|
@@ -32,7 +32,9 @@ internal static class CSharpSyntaxTokens | |
| public static readonly SyntaxToken EndOfDocumentationCommentToken = Token(SyntaxKind.EndOfDocumentationCommentToken); | ||
| public static readonly SyntaxToken EqualsToken = Token(SyntaxKind.EqualsToken); | ||
| public static readonly SyntaxToken ExplicitKeyword = Token(SyntaxKind.ExplicitKeyword); | ||
| #if !ROSLYN_4_12_OR_LOWER | ||
| public static readonly SyntaxToken ExtensionKeyword = Token(SyntaxKind.ExtensionKeyword); | ||
| #endif | ||
|
Member
Author
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. will be used in RoslynAnalyzers, which will only be able to reference up to Ros 4.12 (we're currently at ros 4.14). |
||
| public static readonly SyntaxToken ExternKeyword = Token(SyntaxKind.ExternKeyword); | ||
| public static readonly SyntaxToken FileKeyword = Token(SyntaxKind.FileKeyword); | ||
| public static readonly SyntaxToken FixedKeyword = Token(SyntaxKind.FixedKeyword); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ | |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| #pragma warning disable CS1574 // XML comment has cref attribute that could not be resolved | ||
|
Member
Author
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. some comments that don't result when this is pulled into libs that don't reference all of the shared side of roslyn workspace. |
||
|
|
||
| using System.Xml.Linq; | ||
| using Microsoft.CodeAnalysis.CSharp.CodeStyle; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -405,7 +405,11 @@ IdentifierNameSyntax nameSyntax when IsInPreprocessingSymbolContext(nameSyntax) | |
| }; | ||
|
|
||
| private static IPreprocessingSymbol? CreatePreprocessingSymbol(SemanticModel model, SyntaxToken identifier) | ||
| #if !ROSLYN_4_12_OR_LOWER | ||
| => model.Compilation.CreatePreprocessingSymbol(identifier.ValueText); | ||
| #else | ||
| => null; | ||
| #endif | ||
|
|
||
| private static bool IsInPreprocessingSymbolContext(SyntaxNode node) | ||
| => node.Ancestors().Any(n => n.Kind() is | ||
|
|
@@ -417,7 +421,7 @@ SyntaxKind.DefineDirectiveTrivia or | |
| public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor) | ||
| => typeSymbol.TryGetPrimaryConstructor(out primaryConstructor); | ||
|
|
||
| #if !CODE_STYLE | ||
| #if CSHARP_WORKSPACE | ||
|
Member
Author
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. RoslynAnalyzers is also "!CODE_STYLE". so that breaks badly when sharing these files. i didn't feel comfortable defining that constnat for RoslynAnalyzers. So instead, i just flipped these to be either |
||
|
|
||
| public async Task<ISymbol?> GetInterceptorSymbolAsync(Document document, int position, CancellationToken cancellationToken) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,26 +8,6 @@ namespace Microsoft.CodeAnalysis.Diagnostics; | |
|
|
||
| internal static partial class DiagnosticSeverityExtensions | ||
| { | ||
| /// <summary> | ||
| /// Returns the equivalent <see cref="ReportDiagnostic"/> for a <see cref="DiagnosticSeverity"/> value. | ||
| /// </summary> | ||
| /// <param name="diagnosticSeverity">The <see cref="DiagnosticSeverity"/> value.</param> | ||
| /// <returns> | ||
| /// The equivalent <see cref="ReportDiagnostic"/> for the <see cref="DiagnosticSeverity"/> value. | ||
| /// </returns> | ||
| /// <exception cref="InvalidOperationException"> | ||
| /// If <paramref name="diagnosticSeverity"/> is not one of the expected values. | ||
| /// </exception> | ||
| public static ReportDiagnostic ToReportDiagnostic(this DiagnosticSeverity diagnosticSeverity) | ||
| => diagnosticSeverity switch | ||
| { | ||
| DiagnosticSeverity.Hidden => ReportDiagnostic.Hidden, | ||
| DiagnosticSeverity.Info => ReportDiagnostic.Info, | ||
| DiagnosticSeverity.Warning => ReportDiagnostic.Warn, | ||
| DiagnosticSeverity.Error => ReportDiagnostic.Error, | ||
| _ => throw ExceptionUtilities.UnexpectedValue(diagnosticSeverity), | ||
| }; | ||
|
Member
Author
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. moved to better location. |
||
|
|
||
| public static string ToEditorConfigString(this DiagnosticSeverity diagnosticSeverity) | ||
| { | ||
| return diagnosticSeverity switch | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,64 +9,6 @@ namespace Microsoft.CodeAnalysis.Diagnostics; | |
|
|
||
| internal static partial class ReportDiagnosticExtensions | ||
| { | ||
| /// <summary> | ||
| /// Returns the equivalent <see cref="DiagnosticSeverity"/> for a <see cref="ReportDiagnostic"/> value. | ||
| /// </summary> | ||
| /// <param name="reportDiagnostic">The <see cref="ReportDiagnostic"/> value.</param> | ||
| /// <returns> | ||
| /// The equivalent <see cref="DiagnosticSeverity"/> for a <see cref="ReportDiagnostic"/> value; otherwise, | ||
| /// <see langword="null"/> if <see cref="DiagnosticSeverity"/> does not contain a direct equivalent for | ||
| /// <paramref name="reportDiagnostic"/>. | ||
| /// </returns> | ||
| /// <exception cref="InvalidOperationException"> | ||
| /// If <paramref name="reportDiagnostic"/> is not one of the expected values. | ||
| /// </exception> | ||
| public static DiagnosticSeverity? ToDiagnosticSeverity(this ReportDiagnostic reportDiagnostic) | ||
| { | ||
| switch (reportDiagnostic) | ||
| { | ||
| case ReportDiagnostic.Error: | ||
| return DiagnosticSeverity.Error; | ||
|
|
||
| case ReportDiagnostic.Warn: | ||
| return DiagnosticSeverity.Warning; | ||
|
|
||
| case ReportDiagnostic.Info: | ||
| return DiagnosticSeverity.Info; | ||
|
|
||
| case ReportDiagnostic.Hidden: | ||
| return DiagnosticSeverity.Hidden; | ||
|
|
||
| case ReportDiagnostic.Suppress: | ||
| case ReportDiagnostic.Default: | ||
| return null; | ||
|
|
||
| default: | ||
| throw ExceptionUtilities.UnexpectedValue(reportDiagnostic); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Applies a default severity to a <see cref="ReportDiagnostic"/> value. | ||
| /// </summary> | ||
| /// <param name="reportDiagnostic">The <see cref="ReportDiagnostic"/> value.</param> | ||
| /// <param name="defaultSeverity">The default severity.</param> | ||
| /// <returns> | ||
| /// <para>If <paramref name="reportDiagnostic"/> is <see cref="ReportDiagnostic.Default"/>, returns | ||
| /// <paramref name="defaultSeverity"/>.</para> | ||
| /// <para>-or-</para> | ||
| /// <para>Otherwise, returns <paramref name="reportDiagnostic"/> if it has a non-default value.</para> | ||
| /// </returns> | ||
| public static ReportDiagnostic WithDefaultSeverity(this ReportDiagnostic reportDiagnostic, DiagnosticSeverity defaultSeverity) | ||
| { | ||
| if (reportDiagnostic != ReportDiagnostic.Default) | ||
| { | ||
| return reportDiagnostic; | ||
| } | ||
|
|
||
| return defaultSeverity.ToReportDiagnostic(); | ||
| } | ||
|
Member
Author
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. moved to better location. |
||
|
|
||
| public static string ToEditorConfigString(this ReportDiagnostic reportDiagnostic) | ||
| { | ||
| return reportDiagnostic switch | ||
|
|
||
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.
referencing this now in the shrred lib. not as this weird one-off in a real project.