Skip to content

Commit a249d9c

Browse files
Address code review feedback
- IntermediateNodeFormatter: Move const to the method where it is used. - ComponentBindLoweringPass: Add missing type pattern to switch expression. - ComponentMarkupDiagnosticPass: Replace expressions with existing local.
1 parent 22e6385 commit a249d9c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentBindLoweringPass.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,7 @@ IntermediateToken GetToken(IntermediateNode parent)
11461146
var originalSpan = node switch
11471147
{
11481148
ComponentAttributeIntermediateNode n => n.OriginalAttributeSpan,
1149+
TagHelperDirectiveAttributeIntermediateNode n => n.OriginalAttributeSpan,
11491150
TagHelperDirectiveAttributeParameterIntermediateNode n => n.OriginalAttributeSpan,
11501151
TagHelperPropertyIntermediateNode n => n.OriginalAttributeSpan,
11511152
_ => null

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentDuplicateAttributeDiagnosticPass.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ public override void VisitMarkupElement(MarkupElementIntermediateNode node)
4444

4545
if (originalAttributeName != null)
4646
{
47-
other.node.AddDiagnostic(ComponentDiagnosticFactory.Create_DuplicateMarkupAttributeDirective(
47+
otherAttribute.AddDiagnostic(ComponentDiagnosticFactory.Create_DuplicateMarkupAttributeDirective(
4848
other.name,
4949
originalAttributeName,
50-
other.node.Source ?? node.Source));
50+
otherAttribute.Source ?? node.Source));
5151
}
5252
else
5353
{
5454
// This is a conflict in the code the user wrote.
55-
other.node.AddDiagnostic(ComponentDiagnosticFactory.Create_DuplicateMarkupAttribute(
55+
otherAttribute.AddDiagnostic(ComponentDiagnosticFactory.Create_DuplicateMarkupAttribute(
5656
other.name,
57-
other.node.Source ?? node.Source));
57+
otherAttribute.Source ?? node.Source));
5858
}
5959
}
6060

src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Intermediate/IntermediateNodeFormatter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public enum FormatterMode
2828
PreferProperties,
2929
}
3030

31-
private const string ShortNameSuffix = nameof(IntermediateNode);
3231
private static readonly Dictionary<Type, string> s_nodeTypeToShortNameMap = [];
3332

3433
private static readonly char[] s_charsToEscape = ['\r', '\n', '\t'];
@@ -49,6 +48,8 @@ private static string GetNodeShortName(IntermediateNode node)
4948

5049
static string ComputeShortName(Type type)
5150
{
51+
const string ShortNameSuffix = nameof(IntermediateNode);
52+
5253
var shortName = type.Name;
5354

5455
if (shortName.EndsWith(ShortNameSuffix, StringComparison.Ordinal))

0 commit comments

Comments
 (0)