Skip to content

Commit 2a1142b

Browse files
committed
chore: clean up all the stuff to make sure the initial_branch is ready to go
1 parent a1899c0 commit 2a1142b

File tree

6 files changed

+24
-50
lines changed

6 files changed

+24
-50
lines changed

CodeJoyRide.Fx.Analyzer/CodeJoyRide.Fx.Analyzer/AnalyzerReleases.Shipped.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
### New Rules
44

5-
| Rule ID | Category | Severity | Notes |
6-
|---------|----------|----------|--------------------------------------------------|
7-
| CJR01 | Usage | Warning | The speed must be lower than the Speed of Light. |
5+
Rule ID | Category | Severity | Notes
6+
--------|----------|----------|--------------------
7+
CJR001 | Usage | Error | The speed must be lower than the Speed of Light.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
### New Rules
22

3-
| Rule ID | Category | Severity | Notes |
4-
|---------|----------|----------|-------|
3+
Rule ID | Category | Severity | Notes
4+
--------|----------|----------|--------------------

CodeJoyRide.Fx.Analyzer/CodeJoyRide.Fx.Analyzer/MaybeCodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
4646

4747
// Register a code action that will invoke the fix.
4848
context.RegisterCodeFix(CodeAction.Create(
49-
title: string.Format(Resources.CJR01CodeFixTitle, "throw", "Maybe.None"),
49+
title: string.Format(Resources.CJR001CodeFixTitle, "throw", "Maybe.None"),
5050
token => ReplaceThrowWithReturnStatement(context.Document, throwStatementSyntax, token),
51-
equivalenceKey: nameof(Resources.CJR01CodeFixTitle)
51+
equivalenceKey: nameof(Resources.CJR001CodeFixTitle)
5252
), diagnostic);
5353
}
5454

CodeJoyRide.Fx.Analyzer/CodeJoyRide.Fx.Analyzer/MaybeSemanticAnalyzer.cs

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ namespace CodeJoyRide.Fx.Analyzer;
1616
public class MaybeSemanticAnalyzer : DiagnosticAnalyzer
1717
{
1818
// Preferred format of DiagnosticId is Your Prefix + Number, e.g. CA1234.
19-
public const string DiagnosticId = "CJR01";
19+
public const string DiagnosticId = "CJR001";
2020

2121
// Feel free to use raw strings if you don't need localization.
22-
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.CJR01Title),
22+
private static readonly LocalizableString Title = new LocalizableResourceString(nameof(Resources.CJR001Title),
2323
Resources.ResourceManager, typeof(Resources));
2424

2525
// The message that will be displayed to the user.
2626
private static readonly LocalizableString MessageFormat =
27-
new LocalizableResourceString(nameof(Resources.CJR01MessageFormat), Resources.ResourceManager,
27+
new LocalizableResourceString(nameof(Resources.CJR001MessageFormat), Resources.ResourceManager,
2828
typeof(Resources));
2929

3030
private static readonly LocalizableString Description =
31-
new LocalizableResourceString(nameof(Resources.CJR01Description), Resources.ResourceManager,
31+
new LocalizableResourceString(nameof(Resources.CJR001Description), Resources.ResourceManager,
3232
typeof(Resources));
3333

3434
// The category of the diagnostic (Design, Naming etc.).
@@ -57,32 +57,6 @@ public override void Initialize(AnalysisContext context)
5757

5858
private void AnalyzeThrowStatements(OperationAnalysisContext context)
5959
{
60-
if (context.Operation is not IThrowOperation || context.Operation.Syntax is not ThrowStatementSyntax)
61-
return;
62-
63-
if (context.Operation.SemanticModel is null)
64-
return;
65-
66-
var containingMethodSyntax = GetContainingMethodSyntax(context.Operation.Syntax);
67-
var containingMethodSymbol =
68-
context.Operation.SemanticModel.GetDeclaredSymbol(containingMethodSyntax) as IMethodSymbol;
69-
70-
var returnTypeSymbol = containingMethodSymbol!.ReturnType;
71-
var maybeTypeSymbol = context.Compilation.GetTypeByMetadataName("CodeJoyRide.Fx.Maybe`1");
72-
73-
if (!returnTypeSymbol.OriginalDefinition.Equals(maybeTypeSymbol, SymbolEqualityComparer.Default))
74-
return;
75-
76-
var diagnostic = Diagnostic.Create(Rule, context.Operation.Syntax.GetLocation());
77-
context.ReportDiagnostic(diagnostic);
78-
}
79-
80-
private MethodDeclarationSyntax GetContainingMethodSyntax(SyntaxNode syntaxNode)
81-
{
82-
while (true)
83-
{
84-
if (syntaxNode.Parent is MethodDeclarationSyntax mds) return mds;
85-
syntaxNode = syntaxNode.Parent!;
86-
}
60+
// TODO: Implement the Analyzer
8761
}
8862
}

CodeJoyRide.Fx.Analyzer/CodeJoyRide.Fx.Analyzer/Resources.Designer.cs

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeJoyRide.Fx.Analyzer/CodeJoyRide.Fx.Analyzer/Resources.resx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
<resheader name="writer">
1919
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
2020
</resheader>
21-
<data name="CJR01CodeFixTitle" xml:space="preserve">
21+
<data name="CJR001CodeFixTitle" xml:space="preserve">
2222
<value>Replace '{0}' with '{1}'</value><comment>The title of the code fix.</comment>
2323
</data>
24-
<data name="CJR01Description" xml:space="preserve">
24+
<data name="CJR001Description" xml:space="preserve">
2525
<value>It's recommended to return None instead of throw exception.</value><comment>An optional longer localizable description of the diagnostic.</comment>
2626
</data>
27-
<data name="CJR01MessageFormat" xml:space="preserve">
27+
<data name="CJR001MessageFormat" xml:space="preserve">
2828
<value>Use Maybe.None instead of throw exception</value><comment>The format-able message the diagnostic displays.</comment>
2929
</data>
30-
<data name="CJR01Title" xml:space="preserve">
30+
<data name="CJR001Title" xml:space="preserve">
3131
<value>No Throw Exception</value><comment>The title of the diagnostic.</comment>
3232
</data>
3333
</root>

0 commit comments

Comments
 (0)