Skip to content

Commit 5522c1c

Browse files
committed
Fixed SA1135 bug
1 parent 2967e94 commit 5522c1c

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/GenericAnalyzerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static GenericAnalyzerTest()
2525
{
2626
1 => "1.2.1",
2727
2 => "2.8.2",
28-
3 => "3.3.1",
28+
3 => "3.6.0",
2929
_ => throw new InvalidOperationException("Unknown version."),
3030
};
3131

StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SymbolNameHelpers.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace StyleCop.Analyzers.Helpers
55
{
6+
using System.Reflection;
67
using System.Text;
78
using Microsoft.CodeAnalysis;
89
using Microsoft.CodeAnalysis.CSharp;
@@ -46,10 +47,12 @@ public static string ToFullyQualifiedValueTupleDisplayString(this INamedTypeSymb
4647
var tupleElements = tupleSymbol.TupleElements();
4748
if (tupleElements.IsDefault)
4849
{
50+
// If the tuple elements API is not available, the default formatting will produce System.ValueTuple and not the C# tuple format.
4951
return tupleSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
5052
}
5153
else
5254
{
55+
// workaround for SymbolDisplayCompilerInternalOptions.UseValueTuple not being available to us.
5356
var builder = ObjectPools.StringBuilderPool.Allocate();
5457

5558
builder.Append("global::System.ValueTuple<");
@@ -206,7 +209,7 @@ private static bool AppendTupleType(StringBuilder builder, INamedTypeSymbol name
206209
}
207210
else
208211
{
209-
return AppendQualifiedSymbolName(builder, namedTypeSymbol.TupleUnderlyingType(), type);
212+
return AppendNamedType(builder, namedTypeSymbol.TupleUnderlyingTypeOrSelf(), type);
210213
}
211214
}
212215

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1135UsingDirectivesMustBeQualified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static void CheckUsingDeclaration(SyntaxNodeAnalysisContext context, Usi
9595
if (symbol is INamedTypeSymbol typeSymbol
9696
&& typeSymbol.IsTupleType())
9797
{
98-
symbol = typeSymbol.TupleUnderlyingType();
98+
symbol = typeSymbol.TupleUnderlyingTypeOrSelf();
9999
}
100100

101101
string symbolString = symbol.ToQualifiedString(usingDirective.Name);

0 commit comments

Comments
 (0)