Skip to content

Commit 2196ce4

Browse files
authored
Document XsltSettings.EnableScript property obsolescence in .NET 10 (#48297)
1 parent 3125364 commit 2196ce4

File tree

8 files changed

+83
-30
lines changed

8 files changed

+83
-30
lines changed

docs/core/compatibility/core-libraries/10.0/obsolete-apis.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Breaking change: .NET 10 obsoletions with custom IDs"
33
titleSuffix: ""
44
description: Learn about the APIs that have been marked as obsolete in .NET 10 with a custom diagnostic ID.
5-
ms.date: 03/28/2025
5+
ms.date: 09/08/2025
66
ai-usage: ai-assisted
77
---
88
# API obsoletions with non-default diagnostic IDs (.NET 10)
@@ -21,6 +21,7 @@ The following table lists the custom diagnostic IDs and their corresponding warn
2121
| [SYSLIB0059](../../../../fundamentals/syslib-diagnostics/syslib0059.md) | <xref:Microsoft.Win32.SystemEvents.EventsThreadShutdown?displayProperty=nameWithType> callbacks aren't run before the process exits. Use <xref:System.AppDomain.ProcessExit?displayProperty=nameWithType> instead. | Warning |
2222
| [SYSLIB0060](../../../../fundamentals/syslib-diagnostics/syslib0060.md) | <xref:System.Security.Cryptography.Rfc2898DeriveBytes?displayProperty=nameWithType> constructors are obsolete. Use <xref:System.Security.Cryptography.Rfc2898DeriveBytes.Pbkdf2*?displayProperty=nameWithType> instead. | Warning |
2323
| [SYSLIB0061](../../../../fundamentals/syslib-diagnostics/syslib0061.md) | <xref:System.Linq.Queryable.MaxBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=nameWithType> and <xref:System.Linq.Queryable.MinBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=nameWithType> taking an `IComparer<TSource>` are obsolete. Use the new ones that take an `IComparer<TKey>`. | Warning |
24+
| [SYSLIB0062](../../../../fundamentals/syslib-diagnostics/syslib0062.md) | <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> is obsolete. | Warning |
2425

2526
## Version introduced
2627

@@ -64,6 +65,10 @@ These obsoletions can affect [source compatibility](../../categories.md#source-c
6465
- <xref:System.Linq.Queryable.MaxBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=fullName>
6566
- <xref:System.Linq.Queryable.MinBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=fullName>
6667

68+
### SYSLIB0062
69+
70+
- <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=fullName>
71+
6772
## See also
6873

6974
- [API obsoletions with non-default diagnostic IDs (.NET 9)](../9.0/obsolete-apis-with-custom-diagnostics.md)

docs/core/compatibility/unsupported-apis.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Unsupported APIs on .NET Core and .NET 5+
33
titleSuffix: ""
44
description: Learn which .NET APIs always throw an exception on .NET Core and .NET 5 and later versions.
5-
ms.date: 11/22/2024
5+
ms.date: 09/08/2025
66
---
77
# APIs that always throw exceptions on .NET Core and .NET 5+
88

@@ -349,6 +349,7 @@ This article organizes the affected APIs by namespace.
349349
| <xref:System.Xml.XmlDictionaryReader.CreateMtomReader(System.Byte[],System.Int32,System.Int32,System.Text.Encoding[],System.String,System.Xml.XmlDictionaryReaderQuotas,System.Int32,System.Xml.OnXmlDictionaryReaderClose)?displayProperty=nameWithType> | All |
350350
| <xref:System.Xml.XmlDictionaryReader.CreateMtomReader(System.IO.Stream,System.Text.Encoding[],System.String,System.Xml.XmlDictionaryReaderQuotas,System.Int32,System.Xml.OnXmlDictionaryReaderClose)?displayProperty=nameWithType> | All |
351351
| <xref:System.Xml.XmlDictionaryWriter.CreateMtomWriter(System.IO.Stream,System.Text.Encoding,System.Int32,System.String,System.String,System.String,System.Boolean,System.Boolean)?displayProperty=nameWithType> | All |
352+
| <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> (when set to `true`) | All |
352353

353354
## See also
354355

docs/fundamentals/code-analysis/quality-rules/ca3076.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@ f1_keywords:
1717

1818
## Cause
1919

20-
If you execute Extensible Stylesheets Language Transformations (XSLT) in .NET applications insecurely, the processor may resolve untrusted URI references that could disclose sensitive information to attackers, leading to Denial of Service and Cross-Site attacks. For more information, see [XSLT Security Considerations(.NET Guide)](../../../standard/data/xml/xslt-security-considerations.md).
20+
If you execute Extensible Stylesheets Language Transformations (XSLT) in .NET applications insecurely, the processor might resolve untrusted URI references that could disclose sensitive information to attackers, leading to denial of service and cross-site attacks. For more information, see [XSLT Security Considerations (.NET Guide)](../../../standard/data/xml/xslt-security-considerations.md).
2121

2222
## Rule description
2323

24-
**XSLT** is a World Wide Web Consortium (W3C) standard for transforming XML data. XSLT is typically used to write style sheets to transform XML data to other formats such as HTML, fixed-length text, comma-separated text, or a different XML format. Although prohibited by default, you may choose to enable it for your project.
24+
*XSLT* is a World Wide Web Consortium (W3C) standard for transforming XML data. XSLT is typically used to write style sheets to transform XML data to other formats such as HTML, fixed-length text, comma-separated text, or a different XML format. Although prohibited by default, you might choose to enable it for your project.
2525

2626
To ensure you're not exposing an attack surface, this rule triggers whenever the XslCompiledTransform.<xref:System.Xml.Xsl.XslCompiledTransform.Load%2A> receives insecure combination instances of <xref:System.Xml.Xsl.XsltSettings> and <xref:System.Xml.XmlResolver>, which allows malicious script processing.
2727

2828
## How to fix violations
2929

30-
- Replace the insecure XsltSettings argument with XsltSettings.<xref:System.Xml.Xsl.XsltSettings.Default%2A> or with an instance that has disabled document function and script execution.
31-
30+
- Replace the insecure `XsltSettings` argument with <xref:System.Xml.Xsl.XsltSettings.Default?displayProperty=nameWithType> or with an instance that's disabled document function and script execution.
3231
- Replace the <xref:System.Xml.XmlResolver> argument with null or an <xref:System.Xml.XmlSecureResolver> instance.
3332

3433
## When to suppress warnings
@@ -150,6 +149,9 @@ namespace TestNamespace
150149
}
151150
```
152151

152+
> [!NOTE]
153+
> Starting in .NET 10, the <xref:System.Xml.Xsl.XsltSettings.EnableScript%2A> property is marked as obsolete and generates warning `SYSLIB0062`. On .NET (Core), it's no longer necessary to explicitly set this property to `false` since script execution isn't supported.
154+
153155
## See also
154156

155-
- [XSLT Security Considerations(.NET Guide)](../../../standard/data/xml/xslt-security-considerations.md)
157+
- [XSLT Security Considerations (.NET Guide)](../../../standard/data/xml/xslt-security-considerations.md)

docs/fundamentals/syslib-diagnostics/obsoletions-overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The following table provides an index to the `SYSLIB0XXX` obsoletions in .NET 5+
8282
| [SYSLIB0059](syslib0059.md) | Warning | <xref:Microsoft.Win32.SystemEvents.EventsThreadShutdown?displayProperty=nameWithType> callbacks aren't run before the process exits. Use <xref:System.AppDomain.ProcessExit?displayProperty=nameWithType> instead. |
8383
| [SYSLIB0060](syslib0060.md) | Warning | Constructors on <xref:System.Security.Cryptography.Rfc2898DeriveBytes?displayProperty=nameWithType> are obsolete. Use <xref:System.Security.Cryptography.Rfc2898DeriveBytes.Pbkdf2%2A?displayProperty=nameWithType> instead. |
8484
| [SYSLIB0061](syslib0061.md) | Warning | The `Queryable` <xref:System.Linq.Queryable.MaxBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=nameWithType> and <xref:System.Linq.Queryable.MinBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=nameWithType> taking an `IComparer<TSource>` are obsolete. Use the new ones that take an `IComparer<TKey>`. |
85+
| [SYSLIB0062](syslib0062.md) | Warning | <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> is obsolete. |
8586

8687
## Suppress warnings
8788

docs/fundamentals/syslib-diagnostics/syslib0061.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.date: 03/31/2025
55
f1_keywords:
66
- SYSLIB0061
77
---
8-
# SYSLIB0061: System.Linq.Queryable.MaxBy and System.Linq.Queryable.MinBy taking an IComparer\<TSource\> are obsolete.
8+
# SYSLIB0061: System.Linq.Queryable.MaxBy and System.Linq.Queryable.MinBy taking an IComparer\<TSource\> are obsolete
99

1010
Starting in .NET 10, the two extension methods <xref:System.Linq.Queryable.MaxBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=fullName> and <xref:System.Linq.Queryable.MinBy``2(System.Linq.IQueryable{``0},System.Linq.Expressions.Expression{System.Func{``0,``1}},System.Collections.Generic.IComparer{``0})?displayProperty=fullName> that accept an `IComparer<TSource>` are obsolete. Please use the newly added overloads that accept an `IComparer<TKey>` instead.
1111

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: SYSLIB0062 warning - XsltSettings.EnableScript is obsolete
3+
description: Learn about the obsoletion of the XsltSettings.EnableScript property. Use of this property generates compile-time warning SYSLIB0062.
4+
ms.date: 09/08/2025
5+
f1_keywords:
6+
- SYSLIB0062
7+
---
8+
# SYSLIB0062: XsltSettings.EnableScript is obsolete
9+
10+
Starting in .NET 10, the <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> property is marked obsolete.
11+
12+
## Reason for obsoletion
13+
14+
XSLT script blocks aren't supported on .NET (Core). Previously, if you set the property to `true`, a <xref:System.PlatformNotSupportedException> was thrown at run time. This obsoletion turns a run-time error into a build warning, which provides better guidance for migration.
15+
16+
## Workaround
17+
18+
Review call sites for any assumptions made about the behavior of this property. You can likely remove any references to the property since it didn't truly enable script blocks on modern .NET.
19+
20+
## Suppress a warning
21+
22+
If you must use the obsolete API, you can suppress the warning in code or in your project file.
23+
24+
To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.
25+
26+
```csharp
27+
// Disable the warning.
28+
#pragma warning disable SYSLIB0062
29+
30+
// Code that uses obsolete API.
31+
// ...
32+
33+
// Re-enable the warning.
34+
#pragma warning restore SYSLIB0062
35+
```
36+
37+
To suppress all the `SYSLIB0062` warnings in your project, add a `<NoWarn>` property to your project file.
38+
39+
```xml
40+
<Project Sdk="Microsoft.NET.Sdk">
41+
<PropertyGroup>
42+
...
43+
<NoWarn>$(NoWarn);SYSLIB0062</NoWarn>
44+
</PropertyGroup>
45+
</Project>
46+
```
47+
48+
For more information, see [Suppress warnings](obsoletions-overview.md#suppress-warnings).

docs/navigate/tools-diagnostics/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4022,6 +4022,8 @@ items:
40224022
href: ../../fundamentals/syslib-diagnostics/syslib0060.md
40234023
- name: SYSLIB0061
40244024
href: ../../fundamentals/syslib-diagnostics/syslib0061.md
4025+
- name: SYSLIB0062
4026+
href: ../../fundamentals/syslib-diagnostics/syslib0062.md
40254027
- name: Experimental features
40264028
items:
40274029
- name: Overview

docs/standard/data/xml/script-blocks-using-msxsl-script.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,24 @@ dev_langs:
77
- "vb"
88
ms.assetid: fde6f43f-c594-486f-abcb-2211197fae20
99
---
10-
# Script Blocks Using msxsl:script
10+
# Script blocks Using msxsl:script
1111

1212
> [!NOTE]
1313
> Script blocks are supported only in .NET Framework. They are _not_ supported on .NET Core or .NET 5 or later.
1414
1515
The <xref:System.Xml.Xsl.XslCompiledTransform> class supports embedded scripts using the `msxsl:script` element. When the style sheet is loaded, any defined functions are compiled to common intermediate language (CIL) by the Code Document Object Model (CodeDOM) and are executed during run time. The assembly generated from the embedded script block is separate than the assembly generated for the style sheet.
1616

17-
## Enable XSLT Script
17+
## Enable XSLT script
1818

19-
Support for embedded scripts is an optional XSLT setting on the <xref:System.Xml.Xsl.XslCompiledTransform> class. Script support is disabled by default. To enable script support, create an <xref:System.Xml.Xsl.XsltSettings> object with the <xref:System.Xml.Xsl.XsltSettings.EnableScript%2A> property set to `true` and pass the object to the <xref:System.Xml.Xsl.XslCompiledTransform.Load%2A> method.
19+
Support for embedded scripts is an optional XSLT setting on the <xref:System.Xml.Xsl.XslCompiledTransform> class. Script support is disabled by default. To enable script support, create an <xref:System.Xml.Xsl.XsltSettings> object with the <xref:System.Xml.Xsl.XsltSettings.EnableScript%2A> property set to `true` and pass the object to the <xref:System.Xml.Xsl.XslCompiledTransform.Load%2A> method.
20+
21+
> [!WARNING]
22+
> Starting in .NET 10, the <xref:System.Xml.Xsl.XsltSettings.EnableScript%2A> property is marked as obsolete and generates warning SYSLIB0062. Since script blocks aren't supported on .NET Core or .NET 5+, this property has no effect and setting it to `true` throws a <xref:System.PlatformNotSupportedException> at run time.
2023
2124
> [!NOTE]
2225
> XSLT scripting should be enabled only if you require script support and you are working in a fully trusted environment.
2326
24-
## msxsl:script Element Definition
27+
## msxsl:script element definition
2528

2629
The `msxsl:script` element is a Microsoft extension to the XSLT 1.0 recommendation and has the following definition:
2730

@@ -46,25 +49,25 @@ The <xref:System.Xml.Xsl.XslCompiledTransform> class supports embedded scripts u
4649
</msxsl:script>
4750
```
4851

49-
## Script Functions
52+
## Script functions
5053

5154
Functions can be declared within the `msxsl:script` element. When a function is declared, it is contained in a script block. Style sheets can contain multiple script blocks, each operating independent of the other. That means that if you are executing inside a script block, you cannot call a function that you defined in another script block unless it is declared to have the same namespace and the same scripting language. Because each script block can be in its own language, and the block is parsed according to the grammar rules of that language parser we recommend that you use the correct syntax for the language in use. For example, if you are in a Microsoft C# script block, use the C# comment syntax.
5255

5356
The supplied arguments and return values to the function can be of any type. Because the W3C XPath types are a subset of the common language runtime (CLR) types, type conversion takes place on types that are not considered to be an XPath type. The following table shows the corresponding W3C types and the equivalent CLR type.
5457

55-
|W3C type|CLR type|
56-
|--------------|--------------|
57-
|`String`|<xref:System.String>|
58-
|`Boolean`|<xref:System.Boolean>|
59-
|`Number`|<xref:System.Double>|
60-
|`Result Tree Fragment`|<xref:System.Xml.XPath.XPathNavigator>|
61-
|`Node Set`|<xref:System.Xml.XPath.XPathNodeIterator>|
58+
| W3C type | CLR type |
59+
|------------------------|-------------------------------------------|
60+
| `String` | <xref:System.String> |
61+
| `Boolean` | <xref:System.Boolean> |
62+
| `Number` | <xref:System.Double> |
63+
| `Result Tree Fragment` | <xref:System.Xml.XPath.XPathNavigator> |
64+
| `Node Set` | <xref:System.Xml.XPath.XPathNodeIterator> |
6265

6366
CLR numeric types are converted to <xref:System.Double>. The <xref:System.DateTime> type is converted to <xref:System.String>. <xref:System.Xml.XPath.IXPathNavigable> types are converted to <xref:System.Xml.XPath.XPathNavigator>. **XPathNavigator[]** is converted to <xref:System.Xml.XPath.XPathNodeIterator>.
6467

6568
All other types throw an error.
6669

67-
### Importing Namespaces and Assemblies
70+
### Import namespaces and assemblies
6871

6972
The <xref:System.Xml.Xsl.XslCompiledTransform> class predefines a set of assemblies and namespaces that are supported by default by the `msxsl:script` element. However, you can use classes and members belonging to a namespace that is not on the predefined list by importing the assembly and namespace in `msxsl:script` block.
7073

@@ -73,9 +76,7 @@ The <xref:System.Xml.Xsl.XslCompiledTransform> class supports embedded scripts u
7376
The following two assemblies are referenced by default:
7477

7578
- System.dll
76-
7779
- System.Xml.dll
78-
7980
- Microsoft.VisualBasic.dll (when the script language is VB)
8081

8182
You can import the additional assemblies using the `msxsl:assembly` element. This includes the assembly when the style sheet is compiled. The `msxsl:assembly` element has the following definition:
@@ -97,19 +98,12 @@ The <xref:System.Xml.Xsl.XslCompiledTransform> class supports embedded scripts u
9798
The following namespaces are included by default:
9899

99100
- System
100-
101101
- System.Collection
102-
103102
- System.Text
104-
105103
- System.Text.RegularExpressions
106-
107104
- System.Xml
108-
109105
- System.Xml.Xsl
110-
111106
- System.Xml.XPath
112-
113107
- Microsoft.VisualBasic (when the script language is VB)
114108

115109
You can add support for additional namespaces using the `namespace` attribute. The attribute value is the name of the namespace.

0 commit comments

Comments
 (0)