Skip to content
1 change: 1 addition & 0 deletions docs/project/list-of-diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ The PR that reveals the implementation of the `<IncludeInternalObsoleteAttribute
| __`SYSLIB0059`__ | SystemEvents.EventsThreadShutdown callbacks are not run before the process exits. Use AppDomain.ProcessExit instead. |
| __`SYSLIB0060`__ | The constructors on Rfc2898DeriveBytes are obsolete. Use the static Pbkdf2 method instead. |
| __`SYSLIB0061`__ | The Queryable MinBy and MaxBy taking an IComparer\<TSource\> are obsolete. Use the new ones that take an IComparer\<TKey\>. |
| __`SYSLIB0062`__ | XSLT Script blocks are not supported. |

## Analyzer Warnings

Expand Down
3 changes: 3 additions & 0 deletions src/libraries/Common/src/System/Obsoletions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ internal static class Obsoletions
internal const string QueryableMinByMaxByTSourceObsoleteMessage = "The Queryable MinBy and MaxBy taking an IComparer<TSource> are obsolete. Use the new ones that take an IComparer<TKey>.";
internal const string QueryableMinByMaxByTSourceObsoleteDiagId = "SYSLIB0061";

internal const string XsltSettingsEnableScriptMessage = "XSLT Script blocks are not supported.";
internal const string XsltSettingsEnableScriptDiagId = "SYSLIB0062";

// When adding a new diagnostic ID, add it to the table in docs\project\list-of-diagnostics.md as well.
// Keep new const identifiers above this comment.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ internal sealed class Compiler
public int CurrentPrecedence; // Decreases by 1 with each import
public XslNode? StartApplyTemplates;
public RootLevel? Root;
[System.ObsoleteAttribute("XSLT Script blocks are not supported.", DiagnosticId = "SYSLIB0062", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public Scripts Scripts;
public Output Output = new Output();
public List<VarPar> ExternalPars = new List<VarPar>();
Expand All @@ -67,7 +68,9 @@ public Compiler(XsltSettings settings, bool debug, string? scriptAssemblyPath)
ScriptAssemblyPath = scriptAssemblyPath;

CompilerErrorColl = new CompilerErrorCollection();
#pragma warning disable SYSLIB0062 // Scripts field is obsolete
Scripts = new Scripts(this);
#pragma warning restore SYSLIB0062
}

public CompilerErrorCollection Compile(object stylesheet, XmlResolver? xmlResolver, XmlResolver? origResolver, out QilExpression qil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ private QilExpression Compile(Compiler compiler)
}

// Create list of all early bound objects
#pragma warning disable SYSLIB0062 // Scripts field is obsolete
Scripts.TrimSafeDictionary scriptClasses = compiler.Scripts.ScriptClasses;
#pragma warning restore SYSLIB0062
List<EarlyBoundInfo> ebTypes = new List<EarlyBoundInfo>(scriptClasses.Count);
foreach (string key in scriptClasses.Keys)
{
Expand Down Expand Up @@ -261,10 +263,12 @@ private void CompileInitializationCode()
}

// Register all script namespaces
#pragma warning disable SYSLIB0062 // Scripts field is obsolete
foreach (string scriptNs in _compiler.Scripts.ScriptClasses.Keys)
{
init = _f.Add(init, _f.InvokeCheckScriptNamespace(scriptNs));
}
#pragma warning restore SYSLIB0062

if (init.NodeType == QilNodeType.Add)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ QilNode IXPathEnvironment.ResolveFunction(string prefix, string name, IList<QilN
for (int i = 0; i < args.Count; i++)
args[i] = _f.SafeDocOrderDistinct(args[i]);

#pragma warning disable SYSLIB0062 // XsltSettings.EnableScript is obsolete
if (_compiler.Settings.EnableScript)
{
XmlExtensionFunction? scrFunc = _compiler.Scripts.ResolveFunction(name, ns, args.Count, (IErrorHelper)this);
Expand All @@ -229,6 +230,7 @@ QilNode IXPathEnvironment.ResolveFunction(string prefix, string name, IList<QilN
return _f.Error(_lastScope!.SourceLine, SR.Xslt_ScriptsProhibited);
}
}
#pragma warning restore SYSLIB0062

return _f.XsltInvokeLateBound(_f.QName(name, ns, prefix), args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ public XslFlags Function(string prefix, string name, IList<XslFlags> args)
{
// Unknown function. Can be script function or extension function
funcFlags = XslFlags.AnyType;
#pragma warning disable SYSLIB0062 // XsltSettings.EnableScript is obsolete
if (_compiler.Settings.EnableScript && ns != null)
{
XmlExtensionFunction? scrFunc = _compiler.Scripts.ResolveFunction(name, ns, args.Count, default(NullErrorHelper));
Expand Down Expand Up @@ -1175,6 +1176,7 @@ public XslFlags Function(string prefix, string name, IList<XslFlags> args)
}
}
funcFlags |= XslFlags.SideEffects;
#pragma warning restore SYSLIB0062
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,12 +1309,14 @@ private void LoadMsScript(NsDecl? stylesheetNsList)
scriptNs ??= _compiler.CreatePhantomNamespace();
ParseStringAttribute(1, "language");

#pragma warning disable SYSLIB0062 // XsltSettings.EnableScript is obsolete
if (!_compiler.Settings.EnableScript)
{
_compiler.Scripts.ScriptClasses[scriptNs] = null;
_input.SkipNode();
return;
}
#pragma warning restore SYSLIB0062

throw new PlatformNotSupportedException(SR.CompilingScriptsNotSupported); // Not adding any scripts as script compilation is not available
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public bool EnableDocumentFunction
set { _enableDocumentFunction = value; }
}

[Obsolete(Obsoletions.XsltSettingsEnableScriptMessage, DiagnosticId = Obsoletions.XsltSettingsEnableScriptDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
public bool EnableScript
{
get { return _enableScript; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ public void XsltSettings1_2(object param0, object param1, object param2, object
_xsl.Load(_xslFile, xs, new XmlUrlResolver());

xs.EnableDocumentFunction = (bool)param5;
#pragma warning disable SYSLIB0062 // XsltSettings.EnableScript is obsolete
xs.EnableScript = (bool)param6;
#pragma warning restore SYSLIB0062
_xsl.Load(_xslFile, xs, new XmlUrlResolver());

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,7 @@ public XsltSettings() { }
public XsltSettings(bool enableDocumentFunction, bool enableScript) { }
public static System.Xml.Xsl.XsltSettings Default { get { throw null; } }
public bool EnableDocumentFunction { get { throw null; } set { } }
[System.ObsoleteAttribute("XSLT Script blocks are not supported.", DiagnosticId = "SYSLIB0062", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public bool EnableScript { get { throw null; } set { } }
public static System.Xml.Xsl.XsltSettings TrustedXslt { get { throw null; } }
}
Expand Down
Loading