in src/Core/Compiling/Policy/InlinePolicyCompiler.cs [20:60]
public void Handle(ICompilationContext context, InvocationExpressionSyntax node)
{
if (node.ArgumentList.Arguments.Count != 1)
{
context.Report(Diagnostic.Create(
CompilationErrors.ArgumentCountMissMatchForPolicy,
node.ArgumentList.GetLocation(),
MethodName
));
return;
}
var expression = node.ArgumentList.Arguments[0].Expression;
if (expression is not LiteralExpressionSyntax literal)
{
context.Report(Diagnostic.Create(
CompilationErrors.PolicyArgumentIsNotOfRequiredType,
expression.GetLocation(),
MethodName,
"string literal"
));
return;
}
try
{
XElement xml = CreateRazorFromString(literal);
context.AddPolicy(xml);
}
catch (XmlException ex)
{
context.Report(Diagnostic.Create(
CompilationErrors.RequiredParameterHasXmlErrors,
literal.GetLocation(),
"InlinePolicy",
"policy",
ex.ToString()
));
}
}