Skip to content

Commit 8714420

Browse files
authored
Fix route syntax highlighting parameter color (#46208)
1 parent 0a3a01b commit 8714420

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/Framework/App.Ref/src/CompatibilitySuppressions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
3-
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<Suppressions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
44
<Suppression>
55
<DiagnosticId>PKV004</DiagnosticId>
66
<Target>net7.0</Target>

src/Framework/App.Runtime/src/CompatibilitySuppressions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
3-
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<Suppressions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
44
<Suppression>
55
<DiagnosticId>PKV0001</DiagnosticId>
66
<Target>net7.0</Target>

src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/RoutePatternClassifier.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ public void Visit(RoutePatternCatchAllParameterPartNode node)
9494

9595
public void Visit(RoutePatternNameParameterPartNode node)
9696
{
97-
AddClassification(node.ParameterNameToken, ClassificationTypeNames.ParameterName);
97+
// Parameter name should look like a regular parameter.
98+
// ClassificationTypeNames.ParameterName isn't working so temporarily reuse color from JSON syntax:
99+
// https://github.com/dotnet/roslyn/blob/e1ee2f544a7a4f8d536278bed4e180c54919276e/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs#L181
100+
//
101+
// TODO: Fix properly with https://github.com/dotnet/aspnetcore/issues/46207
102+
AddClassification(node.ParameterNameToken, "json - object");
98103
}
99104

100105
public void Visit(RoutePatternPolicyParameterPartNode node)

src/Framework/AspNetCoreAnalyzers/test/RouteEmbeddedLanguage/RoutePatternClassifierTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,6 @@ public void TestAction()
152152
Regex.CharacterClass("one"),
153153
Regex.CharacterClass("]"));
154154
}
155+
156+
private static FormattedClassification Parameter(string name) => new FormattedClassification(name, "json - object");
155157
}

0 commit comments

Comments
 (0)