Skip to content

Commit eeb06ba

Browse files
committed
fix warnings
1 parent b1165e9 commit eeb06ba

File tree

9 files changed

+21
-170
lines changed

9 files changed

+21
-170
lines changed

AspNetCoreAnalyzers/CodeFixes/RenameParameterFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ semanticModel is { } &&
4040
cancellationToken => Renamer.RenameSymbolAsync(
4141
context.Document.Project.Solution,
4242
parameter,
43+
default,
4344
name!,
44-
context.Document.Project.Solution.Options,
4545
cancellationToken),
4646
nameof(RenameParameterFix)),
4747
diagnostic);

AspNetCoreAnalyzers/CodeFixes/RenameTypeFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ semanticModel is { } &&
4040
cancellationToken => Renamer.RenameSymbolAsync(
4141
context.Document.Project.Solution,
4242
parameter,
43+
default,
4344
name!,
44-
context.Document.Project.Solution.Options,
4545
cancellationToken),
4646
nameof(RenameParameterFix)),
4747
diagnostic);

AspNetCoreAnalyzers/Helpers/PathSegment.cs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Diagnostics;
55

66
[DebuggerDisplay("{this.Span.ToString()}")]
7-
internal struct PathSegment : IEquatable<PathSegment>
7+
internal readonly record struct PathSegment
88
{
99
internal PathSegment(StringLiteral literal, int start, int end)
1010
{
@@ -18,31 +18,9 @@ internal PathSegment(StringLiteral literal, int start, int end)
1818

1919
internal TemplateParameter? Parameter { get; }
2020

21-
public static bool operator ==(PathSegment left, PathSegment right)
22-
{
23-
return left.Equals(right);
24-
}
21+
public bool Equals(PathSegment other) => this.Span.Equals(other.Span);
2522

26-
public static bool operator !=(PathSegment left, PathSegment right)
27-
{
28-
return !left.Equals(right);
29-
}
30-
31-
public bool Equals(PathSegment other)
32-
{
33-
return this.Span.Equals(other.Span);
34-
}
35-
36-
public override bool Equals(object? obj)
37-
{
38-
return obj is PathSegment other &&
39-
this.Equals(other);
40-
}
41-
42-
public override int GetHashCode()
43-
{
44-
return this.Span.GetHashCode();
45-
}
23+
public override int GetHashCode() => this.Span.GetHashCode();
4624

4725
internal static bool TryRead(StringLiteral literal, int start, out PathSegment segment)
4826
{

AspNetCoreAnalyzers/Helpers/RouteConstraint.cs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
namespace AspNetCoreAnalyzers;
22

3-
using System;
43
using System.Diagnostics;
54

65
[DebuggerDisplay("{this.Span.ToString()}")]
7-
internal struct RouteConstraint : IEquatable<RouteConstraint>
6+
internal readonly record struct RouteConstraint
87
{
98
internal RouteConstraint(Span span)
109
{
@@ -13,31 +12,9 @@ internal RouteConstraint(Span span)
1312

1413
internal Span Span { get; }
1514

16-
public static bool operator ==(RouteConstraint left, RouteConstraint right)
17-
{
18-
return left.Equals(right);
19-
}
15+
public bool Equals(RouteConstraint other) => this.Span.Equals(other.Span);
2016

21-
public static bool operator !=(RouteConstraint left, RouteConstraint right)
22-
{
23-
return !left.Equals(right);
24-
}
25-
26-
public bool Equals(RouteConstraint other)
27-
{
28-
return this.Span.Equals(other.Span);
29-
}
30-
31-
public override bool Equals(object? obj)
32-
{
33-
return obj is RouteConstraint other &&
34-
this.Equals(other);
35-
}
36-
37-
public override int GetHashCode()
38-
{
39-
return this.Span.GetHashCode();
40-
}
17+
public override int GetHashCode() => this.Span.GetHashCode();
4118

4219
internal static bool TryRead(Span span, int pos, out RouteConstraint constraint)
4320
{

AspNetCoreAnalyzers/Helpers/Span.cs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Microsoft.CodeAnalysis;
55
using Microsoft.CodeAnalysis.Text;
66

7-
internal struct Span : IEquatable<Span>
7+
internal readonly record struct Span
88
{
99
internal Span(StringLiteral literal, int start, int end)
1010
{
@@ -20,26 +20,7 @@ internal Span(StringLiteral literal, int start, int end)
2020

2121
public char this[int index] => this.Literal.ValueText[this.TextSpan.Start + index];
2222

23-
public static bool operator ==(Span left, Span right)
24-
{
25-
return left.Equals(right);
26-
}
27-
28-
public static bool operator !=(Span left, Span right)
29-
{
30-
return !left.Equals(right);
31-
}
32-
33-
public bool Equals(Span other)
34-
{
35-
return this.Literal.Equals(other.Literal) && this.TextSpan == other.TextSpan;
36-
}
37-
38-
public override bool Equals(object? obj)
39-
{
40-
return obj is Span other &&
41-
this.Equals(other);
42-
}
23+
public bool Equals(Span other) => this.Literal.Equals(other.Literal) && this.TextSpan == other.TextSpan;
4324

4425
public override int GetHashCode()
4526
{

AspNetCoreAnalyzers/Helpers/StringLiteral.cs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
namespace AspNetCoreAnalyzers;
22

3-
using System;
43
using System.Diagnostics;
54
using Microsoft.CodeAnalysis;
65
using Microsoft.CodeAnalysis.CSharp.Syntax;
76
using Microsoft.CodeAnalysis.Text;
87

98
[DebuggerDisplay("{this.Text}")]
10-
internal struct StringLiteral : IEquatable<StringLiteral>
9+
internal readonly record struct StringLiteral
1110
{
1211
internal StringLiteral(LiteralExpressionSyntax literalExpression)
1312
{
@@ -39,31 +38,9 @@ internal bool IsVerbatim
3938
}
4039
}
4140

42-
public static bool operator ==(StringLiteral left, StringLiteral right)
43-
{
44-
return left.Equals(right);
45-
}
41+
public bool Equals(StringLiteral other) => this.LiteralExpression.Equals(other.LiteralExpression);
4642

47-
public static bool operator !=(StringLiteral left, StringLiteral right)
48-
{
49-
return !left.Equals(right);
50-
}
51-
52-
public bool Equals(StringLiteral other)
53-
{
54-
return this.LiteralExpression.Equals(other.LiteralExpression);
55-
}
56-
57-
public override bool Equals(object? obj)
58-
{
59-
return obj is StringLiteral other &&
60-
this.Equals(other);
61-
}
62-
63-
public override int GetHashCode()
64-
{
65-
return this.LiteralExpression.GetHashCode();
66-
}
43+
public override int GetHashCode() => this.LiteralExpression.GetHashCode();
6744

6845
internal Location GetLocation(TextSpan textSpan)
6946
{

AspNetCoreAnalyzers/Helpers/TemplateParameter.cs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
namespace AspNetCoreAnalyzers;
22

3-
using System;
43
using System.Collections.Immutable;
54
using System.Diagnostics;
65

76
[DebuggerDisplay("{this.Name.ToString()}")]
8-
internal struct TemplateParameter : IEquatable<TemplateParameter>
7+
internal readonly record struct TemplateParameter
98
{
109
internal TemplateParameter(Span name, ImmutableArray<RouteConstraint> constraints)
1110
{
@@ -17,30 +16,9 @@ internal TemplateParameter(Span name, ImmutableArray<RouteConstraint> constraint
1716

1817
internal ImmutableArray<RouteConstraint> Constraints { get; }
1918

20-
public static bool operator ==(TemplateParameter left, TemplateParameter right)
21-
{
22-
return left.Equals(right);
23-
}
19+
public bool Equals(TemplateParameter other) => this.Name.Equals(other.Name);
2420

25-
public static bool operator !=(TemplateParameter left, TemplateParameter right)
26-
{
27-
return !left.Equals(right);
28-
}
29-
30-
public bool Equals(TemplateParameter other)
31-
{
32-
return this.Name.Equals(other.Name);
33-
}
34-
35-
public override bool Equals(object? obj)
36-
{
37-
return obj is TemplateParameter other && this.Equals(other);
38-
}
39-
40-
public override int GetHashCode()
41-
{
42-
return this.Name.GetHashCode();
43-
}
21+
public override int GetHashCode() => this.Name.GetHashCode();
4422

4523
internal static bool TryParse(Span span, out TemplateParameter result)
4624
{

AspNetCoreAnalyzers/Helpers/UrlAttribute.cs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
namespace AspNetCoreAnalyzers;
22

3-
using System;
43
using Gu.Roslyn.AnalyzerExtensions;
54
using Microsoft.CodeAnalysis;
65
using Microsoft.CodeAnalysis.CSharp;
76
using Microsoft.CodeAnalysis.CSharp.Syntax;
87
using Microsoft.CodeAnalysis.Diagnostics;
98

10-
internal struct UrlAttribute : IEquatable<UrlAttribute>
9+
internal readonly record struct UrlAttribute
1110
{
1211
internal UrlAttribute(AttributeSyntax attribute, ITypeSymbol type, UrlTemplate? urlTemplate)
1312
{
@@ -22,23 +21,7 @@ internal UrlAttribute(AttributeSyntax attribute, ITypeSymbol type, UrlTemplate?
2221

2322
internal UrlTemplate? UrlTemplate { get; }
2423

25-
public static bool operator ==(UrlAttribute left, UrlAttribute right)
26-
{
27-
return left.Equals(right);
28-
}
29-
30-
public static bool operator !=(UrlAttribute left, UrlAttribute right)
31-
{
32-
return !left.Equals(right);
33-
}
34-
35-
public bool Equals(UrlAttribute other)
36-
{
37-
return Equals(this.Attribute, other.Attribute);
38-
}
39-
40-
public override bool Equals(object? obj) => obj is UrlAttribute other &&
41-
this.Equals(other);
24+
public bool Equals(UrlAttribute other) => Equals(this.Attribute, other.Attribute);
4225

4326
public override int GetHashCode() => this.Attribute?.GetHashCode() ?? 0;
4427

AspNetCoreAnalyzers/Helpers/UrlTemplate.cs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace AspNetCoreAnalyzers;
22

3-
using System;
43
using System.Collections.Immutable;
54
using System.Diagnostics;
65
using Microsoft.CodeAnalysis;
@@ -11,7 +10,7 @@
1110
/// https://tools.ietf.org/html/rfc1738.
1211
/// </summary>
1312
[DebuggerDisplay("{this.Literal.LiteralExpression.ToString()}")]
14-
internal struct UrlTemplate : IEquatable<UrlTemplate>
13+
internal readonly record struct UrlTemplate
1514
{
1615
private UrlTemplate(StringLiteral literal, ImmutableArray<PathSegment> path)
1716
{
@@ -23,31 +22,9 @@ private UrlTemplate(StringLiteral literal, ImmutableArray<PathSegment> path)
2322

2423
internal ImmutableArray<PathSegment> Path { get; }
2524

26-
public static bool operator ==(UrlTemplate left, UrlTemplate right)
27-
{
28-
return left.Equals(right);
29-
}
25+
public bool Equals(UrlTemplate other) => this.Literal.Equals(other.Literal);
3026

31-
public static bool operator !=(UrlTemplate left, UrlTemplate right)
32-
{
33-
return !left.Equals(right);
34-
}
35-
36-
public bool Equals(UrlTemplate other)
37-
{
38-
return this.Literal.Equals(other.Literal);
39-
}
40-
41-
public override bool Equals(object? obj)
42-
{
43-
return obj is UrlTemplate other &&
44-
this.Equals(other);
45-
}
46-
47-
public override int GetHashCode()
48-
{
49-
return this.Literal.GetHashCode();
50-
}
27+
public override int GetHashCode() => this.Literal.GetHashCode();
5128

5229
internal static bool TryParse(LiteralExpressionSyntax literal, out UrlTemplate template)
5330
{

0 commit comments

Comments
 (0)