Skip to content

Commit b3a0270

Browse files
Un-nest and rename NameComparisonMode and ValueComparisonMode enums
This is a fairly mechanical change to clean up the NameComparisonMode and ValueComparisonMode enums nested in RequiredAttributeDescriptor. - Un-nest NameComparisonMode from RequiredAttributeDescriptor - Rename NameComparisonMode to RequiredAttributeNameComparison - Un-nest ValueComparisonMode from RequiredAttributeDescriptor - Rename ValueComparisonMode to RequiredAttributeValueComparison - Rename RequiredAttributeDescriptorBuilder.NameComparisonMode property to NameComparison (matches RequiredAttributeDescriptor.NameComparison) - Rename RequiredAttributeDescriptorBuilder.ValueComparisonMode property to ValueComparison (matches RequiredAttributeDescriptor.ValueComparison ) - Rename TestRequiredAttributeDescriptorBuilderExtensions.NameComparisonMode extension method to NameComparison - Rename TestRequiredAttributeDescriptorBuilderExtensions.ValueComparisonMode extension method to ValueComparison
1 parent 00adc9e commit b3a0270

File tree

31 files changed

+261
-265
lines changed

31 files changed

+261
-265
lines changed

src/Compiler/Microsoft.AspNetCore.Razor.Language/legacyTest/Legacy/TagHelperBlockRewriterTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@ public void Rewrites_ComponentDirectiveAttributes()
22302230
.RequireAttributeDescriptor(r =>
22312231
{
22322232
r.Name = "@bind-";
2233-
r.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch;
2233+
r.NameComparison = RequiredAttributeNameComparison.PrefixMatch;
22342234
r.SetMetadata(Attributes.IsDirectiveAttribute);
22352235
}))
22362236
.BoundAttributeDescriptor(attribute =>
@@ -2275,7 +2275,7 @@ public void Rewrites_MinimizedComponentDirectiveAttributes()
22752275
.RequireAttributeDescriptor(r =>
22762276
{
22772277
r.Name = "@bind-";
2278-
r.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch;
2278+
r.NameComparison = RequiredAttributeNameComparison.PrefixMatch;
22792279
r.SetMetadata(Attributes.IsDirectiveAttribute);
22802280
}))
22812281
.BoundAttributeDescriptor(attribute =>

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRazorTagHelperBinderPhaseTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ public void Execute_DirectiveWithoutQuotes_RewritesTagHelpers_TagHelperMatchesEl
266266
ruleBuilder => ruleBuilder
267267
.RequireAttributeDescriptor(attribute => attribute
268268
.Name("a")
269-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)),
269+
.NameComparison(RequiredAttributeNameComparison.FullMatch)),
270270
ruleBuilder => ruleBuilder
271271
.RequireAttributeDescriptor(attribute => attribute
272272
.Name("b")
273-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)),
273+
.NameComparison(RequiredAttributeNameComparison.FullMatch)),
274274
]);
275275

276276
var content = @"
@@ -310,11 +310,11 @@ public void Execute_DirectiveWithQuotes_RewritesTagHelpers_TagHelperMatchesEleme
310310
ruleBuilder => ruleBuilder
311311
.RequireAttributeDescriptor(attribute => attribute
312312
.Name("a")
313-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)),
313+
.NameComparison(RequiredAttributeNameComparison.FullMatch)),
314314
ruleBuilder => ruleBuilder
315315
.RequireAttributeDescriptor(attribute => attribute
316316
.Name("b")
317-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)),
317+
.NameComparison(RequiredAttributeNameComparison.FullMatch)),
318318
]);
319319

320320
var content = @"

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/DefaultRequiredAttributeDescriptorBuilderTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void Build_DisplayNameIsName_NameComparisonFullMatch()
1818

1919
builder
2020
.Name("asp-action")
21-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch);
21+
.NameComparison(RequiredAttributeNameComparison.FullMatch);
2222

2323
// Act
2424
var descriptor = builder.Build();
@@ -37,7 +37,7 @@ public void Build_DisplayNameIsNameWithDots_NameComparisonPrefixMatch()
3737

3838
builder
3939
.Name("asp-route-")
40-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch);
40+
.NameComparison(RequiredAttributeNameComparison.PrefixMatch);
4141

4242
// Act
4343
var descriptor = builder.Build();

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/TestTagHelperDescriptors.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public static IEnumerable<TagHelperDescriptor> CssSelectorTagHelperDescriptors
117117
builder => builder
118118
.RequireAttributeDescriptor(attribute => attribute
119119
.Name("href")
120-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
120+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
121121
.Value("~/")
122-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch)),
122+
.ValueComparison(RequiredAttributeValueComparison.FullMatch)),
123123
}),
124124
CreateTagHelperDescriptor(
125125
tagName: "a",
@@ -130,14 +130,14 @@ public static IEnumerable<TagHelperDescriptor> CssSelectorTagHelperDescriptors
130130
builder => builder
131131
.RequireAttributeDescriptor(attribute => attribute
132132
.Name("href")
133-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
133+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
134134
.Value("~/")
135-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch))
135+
.ValueComparison(RequiredAttributeValueComparison.PrefixMatch))
136136
.RequireAttributeDescriptor(attribute => attribute
137137
.Name("href")
138-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
138+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
139139
.Value("?hello=world")
140-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch)),
140+
.ValueComparison(RequiredAttributeValueComparison.SuffixMatch)),
141141
}),
142142
CreateTagHelperDescriptor(
143143
tagName: "input",
@@ -152,9 +152,9 @@ public static IEnumerable<TagHelperDescriptor> CssSelectorTagHelperDescriptors
152152
builder => builder
153153
.RequireAttributeDescriptor(attribute => attribute
154154
.Name("type")
155-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
155+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
156156
.Value("text")
157-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch)),
157+
.ValueComparison(RequiredAttributeValueComparison.FullMatch)),
158158
}),
159159
CreateTagHelperDescriptor(
160160
tagName: "input",
@@ -169,7 +169,7 @@ public static IEnumerable<TagHelperDescriptor> CssSelectorTagHelperDescriptors
169169
builder => builder
170170
.RequireAttributeDescriptor(attribute => attribute
171171
.Name("ty")
172-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch)),
172+
.NameComparison(RequiredAttributeNameComparison.PrefixMatch)),
173173
}),
174174
CreateTagHelperDescriptor(
175175
tagName: "*",
@@ -180,9 +180,9 @@ public static IEnumerable<TagHelperDescriptor> CssSelectorTagHelperDescriptors
180180
builder => builder
181181
.RequireAttributeDescriptor(attribute => attribute
182182
.Name("href")
183-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
183+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
184184
.Value("~/")
185-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch)),
185+
.ValueComparison(RequiredAttributeValueComparison.PrefixMatch)),
186186
}),
187187
CreateTagHelperDescriptor(
188188
tagName: "*",
@@ -193,7 +193,7 @@ public static IEnumerable<TagHelperDescriptor> CssSelectorTagHelperDescriptors
193193
builder => builder
194194
.RequireAttributeDescriptor(attribute => attribute
195195
.Name("type")
196-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)),
196+
.NameComparison(RequiredAttributeNameComparison.FullMatch)),
197197
}),
198198
};
199199
}

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/Legacy/TagHelperBlockRewriterTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,7 @@ public void Rewrites_ComponentDirectiveAttributes()
24532453
.RequireAttributeDescriptor(r =>
24542454
{
24552455
r.Name = "@bind-";
2456-
r.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch;
2456+
r.NameComparison = RequiredAttributeNameComparison.PrefixMatch;
24572457
r.SetMetadata(Attributes.IsDirectiveAttribute);
24582458
}))
24592459
.BoundAttributeDescriptor(attribute =>
@@ -2498,7 +2498,7 @@ public void Rewrites_MinimizedComponentDirectiveAttributes()
24982498
.RequireAttributeDescriptor(r =>
24992499
{
25002500
r.Name = "@bind-";
2501-
r.NameComparisonMode = RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch;
2501+
r.NameComparison = RequiredAttributeNameComparison.PrefixMatch;
25022502
r.SetMetadata(Attributes.IsDirectiveAttribute);
25032503
}))
25042504
.BoundAttributeDescriptor(attribute =>

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TagHelperBinderTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public static TheoryData RequiredAttributeData
244244
.RequireAttributeDescriptor(attribute =>
245245
attribute
246246
.Name("nodashprefix")
247-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch)))
247+
.NameComparison(RequiredAttributeNameComparison.PrefixMatch)))
248248
.Build();
249249
var catchAllDescriptor = TagHelperDescriptorBuilder.Create("CatchAllTagHelper", "SomeAssembly")
250250
.TagMatchingRuleDescriptor(rule =>
@@ -266,7 +266,7 @@ public static TheoryData RequiredAttributeData
266266
.RequireAttributeDescriptor(attribute =>
267267
attribute
268268
.Name("prefix-")
269-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch)))
269+
.NameComparison(RequiredAttributeNameComparison.PrefixMatch)))
270270
.Build();
271271
ImmutableArray<TagHelperDescriptor> defaultAvailableDescriptors =
272272
[divDescriptor, inputDescriptor, catchAllDescriptor, catchAllDescriptor2];

src/Compiler/Microsoft.AspNetCore.Razor.Language/test/TagHelperMatchingConventionsTest.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,99 +33,99 @@ public static TheoryData RequiredAttributeDescriptorData
3333
{
3434
builder => builder
3535
.Name("route-")
36-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch),
36+
.NameComparison(RequiredAttributeNameComparison.PrefixMatch),
3737
"ROUTE-area",
3838
"manage",
3939
true
4040
},
4141
{
4242
builder => builder
4343
.Name("route-")
44-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch),
44+
.NameComparison(RequiredAttributeNameComparison.PrefixMatch),
4545
"routearea",
4646
"manage",
4747
false
4848
},
4949
{
5050
builder => builder
5151
.Name("route-")
52-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.PrefixMatch),
52+
.NameComparison(RequiredAttributeNameComparison.PrefixMatch),
5353
"route-",
5454
"manage",
5555
false
5656
},
5757
{
5858
builder => builder
5959
.Name("key")
60-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch),
60+
.NameComparison(RequiredAttributeNameComparison.FullMatch),
6161
"KeY",
6262
"value",
6363
true
6464
},
6565
{
6666
builder => builder
6767
.Name("key")
68-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch),
68+
.NameComparison(RequiredAttributeNameComparison.FullMatch),
6969
"keys",
7070
"value",
7171
false
7272
},
7373
{
7474
builder => builder
7575
.Name("key")
76-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
76+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
7777
.Value("value")
78-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch),
78+
.ValueComparison(RequiredAttributeValueComparison.FullMatch),
7979
"key",
8080
"value",
8181
true
8282
},
8383
{
8484
builder => builder
8585
.Name("key")
86-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
86+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
8787
.Value("value")
88-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.FullMatch),
88+
.ValueComparison(RequiredAttributeValueComparison.FullMatch),
8989
"key",
9090
"Value",
9191
false
9292
},
9393
{
9494
builder => builder
9595
.Name("class")
96-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
96+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
9797
.Value("btn")
98-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch),
98+
.ValueComparison(RequiredAttributeValueComparison.PrefixMatch),
9999
"class",
100100
"btn btn-success",
101101
true
102102
},
103103
{
104104
builder => builder
105105
.Name("class")
106-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
106+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
107107
.Value("btn")
108-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.PrefixMatch),
108+
.ValueComparison(RequiredAttributeValueComparison.PrefixMatch),
109109
"class",
110110
"BTN btn-success",
111111
false
112112
},
113113
{
114114
builder => builder
115115
.Name("href")
116-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
116+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
117117
.Value("#navigate")
118-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch),
118+
.ValueComparison(RequiredAttributeValueComparison.SuffixMatch),
119119
"href",
120120
"/home/index#navigate",
121121
true
122122
},
123123
{
124124
builder => builder
125125
.Name("href")
126-
.NameComparisonMode(RequiredAttributeDescriptor.NameComparisonMode.FullMatch)
126+
.NameComparison(RequiredAttributeNameComparison.FullMatch)
127127
.Value("#navigate")
128-
.ValueComparisonMode(RequiredAttributeDescriptor.ValueComparisonMode.SuffixMatch),
128+
.ValueComparison(RequiredAttributeValueComparison.SuffixMatch),
129129
"href",
130130
"/home/index#NAVigate",
131131
false

0 commit comments

Comments
 (0)