1 write to Attributes
Microsoft.AspNetCore.Razor (1)
TagHelpers\TagHelperOutput.cs (1)
50Attributes = attributes;
296 references to Attributes
Microsoft.AspNetCore.Mvc.Razor (2)
TagHelpers\UrlResolutionTagHelper.cs (2)
141/// <paramref name="output"/>'s <see cref="TagHelperOutput.Attributes"/> whose 151var attributes = output.Attributes;
Microsoft.AspNetCore.Mvc.Razor.Test (12)
RazorPageTest.cs (5)
996var htmlAttribute = Assert.Single(output.Attributes); 1041var htmlAttribute = Assert.Single(output.Attributes); 1087var htmlAttribute = Assert.Single(output.Attributes); 1127Assert.Empty(output.Attributes); 1157var htmlAttribute = Assert.Single(output.Attributes);
TagHelpers\UrlResolutionTagHelperTest.cs (7)
87var attribute = Assert.Single(tagHelperOutput.Attributes); 129var attribute = Assert.Single(tagHelperOutput.Attributes); 189var attribute = Assert.Single(tagHelperOutput.Attributes); 247var attribute = Assert.Single(tagHelperOutput.Attributes); 303var attribute = Assert.Single(tagHelperOutput.Attributes); 334var attribute = Assert.Single(tagHelperOutput.Attributes); 429var attribute = Assert.Single(tagHelperOutput.Attributes);
Microsoft.AspNetCore.Mvc.TagHelpers (51)
AnchorTagHelper.cs (1)
169if (output.Attributes.ContainsName(Href))
FormActionTagHelper.cs (2)
184if (output.Attributes.ContainsName(FormAction)) 262output.Attributes.SetAttribute(FormAction, url);
FormTagHelper.cs (1)
169if (output.Attributes.TryGetAttribute(HtmlActionAttributeName, out var actionAttribute))
ImageTagHelper.cs (2)
125Src = output.Attributes[SrcAttributeName].Value as string; 128output.Attributes.SetAttribute(SrcAttributeName, src);
InputTagHelper.cs (3)
205if (!output.Attributes.ContainsName("type")) 207output.Attributes.SetAttribute("type", inputType); 345if (output.Attributes.TryGetAttribute("form", out var formAttribute))
LinkTagHelper.cs (7)
265Href = output.Attributes[HrefAttributeName]?.Value as string; 280var index = output.Attributes.IndexOfName(HrefAttributeName); 281var existingAttribute = output.Attributes[index]; 282output.Attributes[index] = new TagHelperAttribute( 294BuildGlobbedLinkTags(output.Attributes, builder); 303if (mode == Mode.Fallback && HasStyleSheetLinkType(output.Attributes)) 310BuildFallbackBlock(output.Attributes, builder);
OptionTagHelper.cs (2)
71if (!output.Attributes.ContainsName("selected")) 118output.Attributes.Add("selected", "selected");
ScriptTagHelper.cs (7)
257output.Attributes.SetAttribute("type", "importmap"); 279Src = output.Attributes[SrcAttributeName]?.Value as string; 293var index = output.Attributes.IndexOfName(SrcAttributeName); 294var existingAttribute = output.Attributes[index]; 295output.Attributes[index] = new TagHelperAttribute( 307BuildGlobbedScriptTags(output.Attributes, builder); 323BuildFallbackBlock(output.Attributes, builder);
TagHelperOutputExtensions.cs (25)
23/// <see cref="TagHelperOutput.Attributes"/>. 31/// <see cref="TagHelperOutput.Attributes"/> does not contain an attribute with the given 36/// or <paramref name="tagHelperOutput"/>'s <see cref="TagHelperOutput.Attributes"/> may result in copied 48if (!tagHelperOutput.Attributes.ContainsName(attributeName)) 83/// <remarks>Existing <see cref="TagHelperOutput.Attributes"/> on the given <paramref name="tagHelperOutput"/> 92if (!tagHelperOutput.Attributes.ContainsName(attribute.Key)) 94tagHelperOutput.Attributes.Add(attribute.Key, attribute.Value); 98var found = tagHelperOutput.Attributes.TryGetAttribute("class", out var classAttribute); 106tagHelperOutput.Attributes.SetAttribute(newAttribute); 113/// <see cref="TagHelperOutput.Attributes"/>. 126tagHelperOutput.Attributes.Remove(attribute); 132/// <see cref="TagHelperOutput.Attributes"/>. 156if (!tagHelperOutput.Attributes.TryGetAttribute("class", out TagHelperAttribute classAttribute)) 158tagHelperOutput.Attributes.Add("class", classValue); 185tagHelperOutput.Attributes.SetAttribute(newClassAttribute); 191/// <see cref="TagHelperOutput.Attributes"/>. 210if (!tagHelperOutput.Attributes.TryGetAttribute("class", out TagHelperAttribute classAttribute)) 226tagHelperOutput.Attributes.Remove(classAttribute); 249tagHelperOutput.Attributes.SetAttribute(classAttribute.Name, joinedClasses); 253tagHelperOutput.Attributes.Remove(classAttribute); 298var index = IndexOfFirstMatch(previousName, tagHelperOutput.Attributes); 301tagHelperOutput.Attributes.Insert(index + 1, existingAttribute); 313var index = IndexOfFirstMatch(nextName, tagHelperOutput.Attributes); 316tagHelperOutput.Attributes.Insert(index, existingAttribute); 322tagHelperOutput.Attributes.Add(existingAttribute);
ValidationMessageTagHelper.cs (1)
65output.Attributes.ContainsName(DataValidationForAttributeName))
Microsoft.AspNetCore.Mvc.TagHelpers.Test (197)
AnchorTagHelperTest.cs (8)
78Assert.Equal(2, output.Attributes.Count); 79var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("id")); 81attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("href")); 133Assert.Empty(output.Attributes); 185Assert.Empty(output.Attributes); 243Assert.Empty(output.Attributes); 302Assert.Empty(output.Attributes); 360Assert.Empty(output.Attributes);
FormActionTagHelperTest.cs (6)
70output.Attributes, 144output.Attributes, 248var attribute = Assert.Single(output.Attributes); 306var attribute = Assert.Single(output.Attributes); 379var attribute = Assert.Single(output.Attributes); 432var attribute = Assert.Single(output.Attributes);
FormTagHelperTest.cs (22)
114Assert.Equal(2, output.Attributes.Count); 115var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("method")); 117attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("action")); 168Assert.Equal(2, output.Attributes.Count); 169var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("method")); 171attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("action")); 227var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("action")); 285var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("action")); 356Assert.Equal(3, output.Attributes.Count); 357var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("id")); 359attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("method")); 361attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("action")); 425var attribute = Assert.Single(output.Attributes); 453output.Attributes.Add(expectedAttribute); 496var attribute = Assert.Single(output.Attributes); 549Assert.Empty(output.Attributes); 619var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("action")); 673Assert.Empty(output.Attributes); 730Assert.Empty(output.Attributes); 788Assert.Empty(output.Attributes); 842Assert.Empty(output.Attributes); 999var attribute = Assert.Single(output.Attributes);
ImageTagHelperTest.cs (13)
77(string)output.Attributes["src"].Value, 120Assert.Equal(4, output.Attributes.Count); 122for (var i = 0; i < expectedOutput.Attributes.Count; i++) 124var expectedAttribute = expectedOutput.Attributes[i]; 125var actualAttribute = output.Attributes[i]; 159Assert.Equal(2, output.Attributes.Count); 160var srcAttribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("src")); 211Assert.Equal(2, output.Attributes.Count); 212var srcAttribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("src")); 254Assert.Equal(2, output.Attributes.Count); 255var srcAttribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("src")); 286Assert.Equal(2, output.Attributes.Count); 287var srcAttribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("src"));
InputTagHelperTest.cs (26)
391Assert.Equal(expectedAttributes, output.Attributes); 447Assert.Equal(expectedAttributes, output.Attributes); 498Assert.Equal(expectedAttributes, output.Attributes); 554Assert.Equal(expectedAttributes, output.Attributes); 686Assert.Equal(expectedAttributes, output.Attributes); 757Assert.Equal(expectedAttributes, output.Attributes); 828Assert.Equal(expectedAttributes, output.Attributes); 954Assert.Equal(expectedAttributes, output.Attributes); 1014Assert.Equal(expectedAttributes, output.Attributes); 1074Assert.Equal(expectedAttributes, output.Attributes); 1134Assert.Equal(expectedAttributes, output.Attributes); 1209Assert.NotEmpty(output.Attributes); 1315Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default); 1377Assert.Equal(expectedAttributes, output.Attributes); 1480Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default); 1575Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default); 1693Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default); 1809Assert.Equal(expectedAttributes, output.Attributes); 1878Assert.Equal(expectedAttributes, output.Attributes); 1947Assert.Equal(expectedAttributes, output.Attributes); 2041Assert.Equal(expectedAttributes, output.Attributes); 2110Assert.Equal(expectedAttributes, output.Attributes); 2167Assert.Equal(expectedAttributes, output.Attributes); 2242Assert.Equal(expectedAttributes, output.Attributes); 2303Assert.Equal(expectedAttributes, output.Attributes); 2366Assert.Equal(expectedAttributes, output.Attributes);
LabelTagHelperTest.cs (2)
218Assert.Equal(expectedAttributes, output.Attributes); 327Assert.Equal(expectedAttributes, output.Attributes);
LinkTagHelperTest.cs (20)
75(string)output.Attributes["href"].Value, 159var expectedAttributes = new TagHelperAttributeList(output.Attributes) 168Assert.Equal(expectedAttributes, output.Attributes); 443Assert.Equal("rel", output.Attributes[0].Name); 444Assert.Equal("href", output.Attributes[1].Name); 445Assert.Equal("data-extra", output.Attributes[2].Name); 542Assert.Empty(output.Attributes); 561Assert.Empty(output.Attributes); 600Assert.Equal("/css/site.css", output.Attributes["href"].Value); 641Assert.Equal("/css/site.css", output.Attributes["href"].Value); 694Assert.Equal("/css/site.css", output.Attributes["href"].Value); 725Assert.Equal("/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value); 759Assert.Equal(expected, output.Attributes["href"].Value); 801Assert.Equal("/approot/css/site.fingerprint.css", output.Attributes["href"].Value); 831Assert.Equal("/bar/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value); 884Assert.Equal("/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value); 939Assert.Equal("/css/site.fingerprint.css", output.Attributes["href"].Value); 1009Assert.Equal("/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value); 1049Assert.Equal("/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value); 1091Assert.Equal("/css/site.fingerprint.css", output.Attributes["href"].Value);
OptionTagHelperTest.cs (4)
438Assert.Equal(expectedTagHelperOutput.Attributes.Count, output.Attributes.Count); 439foreach (var attribute in output.Attributes) 441Assert.Contains(attribute, expectedTagHelperOutput.Attributes);
ScriptTagHelperTest.cs (21)
74(string)output.Attributes["src"].Value, 106var expectedAttributes = new TagHelperAttributeList(output.Attributes); 113Assert.Equal(expectedAttributes, output.Attributes); 470Assert.Empty(output.Attributes); 490Assert.Empty(output.Attributes); 524Assert.Equal("data-extra", output.Attributes[0].Name); 525Assert.Equal("src", output.Attributes[1].Name); 526Assert.Equal("data-more", output.Attributes[2].Name); 559Assert.Equal("/js/site.js", output.Attributes["src"].Value); 612Assert.Equal("/js/site.js", output.Attributes["src"].Value); 638Assert.Equal("/js/site.js?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["src"].Value); 668Assert.Equal(expected, output.Attributes["src"].Value); 706Assert.Equal("/approot/js/site.fingerprint.js", output.Attributes["src"].Value); 833Assert.Equal("/bar/js/site.js?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["src"].Value); 861Assert.Equal("/js/site.js?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["src"].Value); 893Assert.Equal("/js/site.fingerprint.js", output.Attributes["src"].Value); 946Assert.Equal("/js/site.js?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["src"].Value); 984Assert.Equal("/js/site.js?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["src"].Value); 1023Assert.Equal("/js/site.fingerprint.js", output.Attributes["src"].Value); 1062Assert.Equal("module", output.Attributes["type"].Value); 1063Assert.Equal("/approot/js/site.fingerprint.js", output.Attributes["src"].Value);
SelectTagHelperTest.cs (6)
240Assert.Equal(expectedAttributes, output.Attributes); 339Assert.Equal(expectedAttributes, output.Attributes); 420Assert.Equal(expectedAttributes, output.Attributes); 519Assert.Equal(expectedAttributes, output.Attributes); 774var attribute = Assert.Single(output.Attributes); 823var attribute = Assert.Single(output.Attributes);
TagHelperOutputExtensionsTest.cs (41)
349Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default); 451Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default); 483var attribute = Assert.Single(tagHelperOutput.Attributes); 518var attribute = Assert.Single(tagHelperOutput.Attributes); 566tagHelperOutput.Attributes.Add(expectedAttribute); 568var attributes = tagHelperOutput.Attributes 576var attribute = Assert.Single(tagHelperOutput.Attributes); 594tagHelperOutput.Attributes.Add(expectedAttribute); 595var attributes = tagHelperOutput.Attributes 602var attribute = Assert.Single(tagHelperOutput.Attributes); 620tagHelperOutput.Attributes.Add(expectedAttribute); 622var attributes = tagHelperOutput.Attributes 629var attribute = Assert.Single(tagHelperOutput.Attributes); 791tagHelperOutput.Attributes, 805tagHelperOutput.Attributes.Add(expectedAttribute); 814var attribute = Assert.Single(tagHelperOutput.Attributes); 827tagHelperOutput.Attributes.Add("class", "Hello"); 838var attribute = Assert.Single(tagHelperOutput.Attributes); 855tagHelperOutput.Attributes.Add(originalName, "Hello"); 864var attribute = Assert.Single(tagHelperOutput.Attributes); 889var attribute = Assert.Single(tagHelperOutput.Attributes); 913Assert.Equal(2, tagHelperOutput.Attributes.Count); 914var attribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("class")); 916attribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("class2")); 930tagHelperOutput.Attributes.Add(expectedAttribute); 938var attribute = Assert.Single(tagHelperOutput.Attributes); 952tagHelperOutput.Attributes.Add(expectedOutputAttribute); 962Assert.Equal(2, tagHelperOutput.Attributes.Count); 963var attribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("class")); 965attribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("for")); 986var classAttribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("class")); 1008var classAttribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("class")); 1034var classAttribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("class")); 1071tagHelperOutput.Attributes.SetAttribute("class", new HtmlString("HtmlEncode[[btn]] HtmlEncode[[btn]]")); 1077var classAttribute = tagHelperOutput.Attributes["class"]; 1094tagHelperOutput.Attributes.SetAttribute("class", new HtmlString("HtmlEncode[[btn]] HtmlEncode[[btn-primary]] HtmlEncode[[btn]]")); 1100var classAttribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("class")); 1115tagHelperOutput.Attributes.SetAttribute("class", new HtmlString("HtmlEncode[[btn]]")); 1121var classAttribute = tagHelperOutput.Attributes["class"]; 1138tagHelperOutput.Attributes.SetAttribute("class", new HtmlString("HtmlEncode[[btn]] HtmlEncode[[btn-primary]]")); 1144var classAttribute = Assert.Single(tagHelperOutput.Attributes, attr => attr.Name.Equals("class"));
TextAreaTagHelperTest.cs (2)
152Assert.Equal(expectedAttributes, output.Attributes); 230var attribute = Assert.Single(output.Attributes);
ValidationMessageTagHelperTest.cs (15)
73Assert.Equal(4, output.Attributes.Count); 74var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("id")); 76attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("class")); 78attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("data-valmsg-for")); 80attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("data-valmsg-replace")); 177Assert.Collection(output.Attributes, 228var attribute = Assert.Single(output.Attributes); 284Assert.Empty(output.Attributes); 346Assert.Equal(2, output.Attributes.Count); 347var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("data-foo")); 349attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("data-hello")); 408Assert.Equal(2, output.Attributes.Count); 409var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("data-foo")); 411attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("data-hello")); 449Assert.Empty(output.Attributes);
ValidationSummaryTagHelperTest.cs (11)
86Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default); 131Assert.Empty(output.Attributes); 199Assert.Empty(output.Attributes); 254Assert.InRange(output.Attributes.Count, low: 1, high: 2); 255var attribute = Assert.Single(output.Attributes, attr => attr.Name.Equals("class")); 325Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default); 386Assert.Empty(output.Attributes); 443output.Attributes, 501Assert.Empty(output.Attributes); 557Assert.Empty(output.Attributes); 638Assert.Equal(expectedAttributes, output.Attributes, CaseSensitiveTagHelperAttributeComparer.Default);
Microsoft.AspNetCore.Razor (8)
TagHelpers\TagHelperOutput.cs (8)
188Attributes.Clear(); 293var count = Attributes.Count; 296var attribute = Attributes[i]; 342var count = Attributes.Count; 345var attribute = Attributes[i]; 378Attributes.Clear(); 397var count = Attributes.Count; 400var attribute = Attributes[i];
Microsoft.AspNetCore.Razor.Runtime (1)
Runtime\TagHelpers\TagHelperExecutionContext.cs (1)
139Output.Attributes.Add(attribute);
Microsoft.AspNetCore.Razor.Runtime.Test (11)
Runtime\TagHelpers\TagHelperExecutionContextTest.cs (4)
132var attribute = Assert.Single(output.Attributes); 466output.Attributes, 489output.Attributes, 520output.Attributes,
Runtime\TagHelpers\TagHelperRunnerTest.cs (7)
167Assert.Equal("somethingelse", output.Attributes["class"].Value); 168Assert.Equal("world", output.Attributes["hello"].Value); 186Assert.Equal("True", executionContext.Output.Attributes["foo"].Value); 216var classIndex = output.Attributes.IndexOfName("class"); 219output.Attributes[classIndex] = new TagHelperAttribute("class", "somethingelse"); 222output.Attributes.Add("hello", "world"); 241output.Attributes.Add("foo", context.AllAttributes["foo"].Value.ToString());
Microsoft.AspNetCore.Razor.Test (6)
TagHelpers\TagHelperOutputTest.cs (6)
48Assert.Empty(output.Attributes); 392tagHelperOutput.Attributes.SetAttribute(updateName, "super button"); 395var attribute = Assert.Single(tagHelperOutput.Attributes); 1047var attributeCount = output.Attributes.Count; 1060Assert.Equal(attributeCount, output.Attributes.Count); 1085Assert.Empty(output.Attributes);
RazorWebSite (2)
Services\TestBodyTagHelperComponent.cs (1)
37output.Attributes.ContainsName("inject"))
Services\TestHeadTagHelperComponent.cs (1)
14if (string.Equals(context.TagName, "head", StringComparison.Ordinal) && output.Attributes.ContainsName("inject"))
TagHelpersWebSite (6)
TagHelpers\AddProcessedAttributeTagHelper.cs (1)
13output.Attributes.Add(new TagHelperAttribute("processed"));
TagHelpers\ATagHelper.cs (3)
34var methodParameters = output.Attributes.ToDictionary(attribute => attribute.Name, 39output.Attributes.Clear(); 42output.Attributes.SetAttribute("href", urlHelper.Action(Action, Controller, methodParameters));
TagHelpers\BoldTagHelper.cs (1)
21output.Attributes.RemoveAll("bold");
TagHelpers\PrettyTagHelper.cs (1)
54output.Attributes.SetAttribute("style", style + prettyStyle);