{"record":{"id":"af39cabcd62b1477","repo":"dotnet/maui","slug":"xc0121","errorCode":"XC0121","errorMessage":"StyleSheet require either a Source or a content.","messagePattern":"StyleSheet require either a Source or a content\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CompiledValueProviders/StyleSheetProvider.cs","lineNumber":30,"sourceCode":"\tclass StyleSheetProvider : ICompiledValueProvider\n\t{\n\t\tpublic IEnumerable<Instruction> ProvideValue(VariableDefinitionReference vardefref, ModuleDefinition module, BaseNode node, ILContext context)\n\t\t{\n\t\t\t((ElementNode)node).Properties.TryGetValue(new XmlName(\"\", \"Source\"), out INode sourceNode);\n\t\t\tif (sourceNode == null)\n\t\t\t\t((ElementNode)node).Properties.TryGetValue(new XmlName(XamlParser.MauiUri, \"Source\"), out sourceNode);\n\n\t\t\tINode styleNode = null;\n\t\t\tif (!((ElementNode)node).Properties.TryGetValue(new XmlName(\"\", \"Style\"), out styleNode) &&\n\t\t\t\t!((ElementNode)node).Properties.TryGetValue(new XmlName(XamlParser.MauiUri, \"Style\"), out styleNode) &&\n\t\t\t\t((ElementNode)node).CollectionItems.Count == 1)\n\t\t\t\tstyleNode = ((ElementNode)node).CollectionItems[0];\n\n\t\t\tif (sourceNode != null && styleNode != null)\n\t\t\t\tthrow new BuildException(BuildExceptionCode.StyleSheetSourceOrContent, node, null);\n\n\t\t\tif (sourceNode == null && styleNode == null)\n\t\t\t\tthrow new BuildException(BuildExceptionCode.StyleSheetNoSourceOrContent, node, null);\n\n\t\t\tif (styleNode != null && styleNode is not ValueNode)\n\t\t\t\tthrow new BuildException(BuildExceptionCode.StyleSheetStyleNotALiteral, node, null);\n\n\t\t\tif (sourceNode != null && sourceNode is not ValueNode)\n\t\t\t\tthrow new BuildException(BuildExceptionCode.StyleSheetSourceNotALiteral, node, null);\n\n\t\t\tif (styleNode != null)\n\t\t\t{\n\t\t\t\tvar style = (styleNode as ValueNode).Value as string;\n\t\t\t\tyield return Create(Ldstr, style);\n\t\t\t\tyield return Create(Call, module.ImportMethodReference(context.Cache, (\"Microsoft.Maui.Controls\", \"Microsoft.Maui.Controls.StyleSheets\", \"StyleSheet\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   methodName: \"FromString\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   parameterTypes: [(\"mscorlib\", \"System\", \"String\")],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   isStatic: true));\n\t\t\t}\n\t\t\telse\n\t\t\t{","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledValueProviders/StyleSheetProvider.cs#L12-L48","documentation":"Thrown by the StyleSheet provider when neither a Source attribute nor inline Style/content is present. The provider needs at least one of them to construct a StyleSheet; with both null it has nothing to compile.","triggerScenarios":"An empty <StyleSheet /> element; a <StyleSheet> whose Style attribute and collection items are both absent; whitespace-only self-closing tag.","commonSituations":"Placeholder element left during scaffolding; copy-paste of a template that stripped the body; refactoring that moved CSS out but left the empty node.","solutions":["Add a Source=\"path.css\" attribute pointing to an embedded resource.","Or add inline CSS as the element's text content / Style attribute.","If unused, delete the <StyleSheet> element entirely."],"exampleFix":"// before\n<StyleSheet />\n// after\n<StyleSheet Source=\"Resources/Styles/app.css\" />","handlingStrategy":"validation","validationCode":"// Lint: a <StyleSheet> must have Source or content\nstatic bool StyleSheetHasAnySource(XElement el) =>\n    el.Attribute(\"Source\") != null || !el.IsEmpty && !string.IsNullOrWhiteSpace(el.Value);\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete empty <StyleSheet /> placeholders before committing.","Use a XAML schema/linter that flags empty required-content elements."],"tags":["xaml","xamlc","stylesheet","css","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}