Skip to content

Commit ff9418a

Browse files
Copilotgewarren
andcommitted
Add breaking change documentation for XsltSettings.EnableScript obsolete (SYSLIB0062)
Co-authored-by: gewarren <[email protected]>
1 parent a488625 commit ff9418a

File tree

5 files changed

+95
-1
lines changed

5 files changed

+95
-1
lines changed

docs/core/compatibility/10.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,9 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
136136
|-------|---------------------------------------|--------------------|
137137
| [Empty ColumnDefinitions and RowDefinitions are disallowed](wpf/10.0/empty-grid-definitions.md) | Source incompatible | Preview 5 |
138138
| [Incorrect usage of DynamicResource causes application crash](wpf/10.0/dynamicresource-crash.md) | Source incompatible/behavioral change | Preview 4 |
139+
140+
## XML and XSLT
141+
142+
| Title | Type of change | Introduced version |
143+
|-------|-------------------|--------------------|
144+
| [XsltSettings.EnableScript property is obsolete](xml/10.0/xsltsettings-enablescript-obsolete.md) | Source incompatible | Preview 1 |

docs/core/compatibility/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ items:
158158
href: wpf/10.0/empty-grid-definitions.md
159159
- name: Incorrect usage of DynamicResource causes application crash
160160
href: wpf/10.0/dynamicresource-crash.md
161+
- name: XML and XSLT
162+
items:
163+
- name: XsltSettings.EnableScript property is obsolete
164+
href: xml/10.0/xsltsettings-enablescript-obsolete.md
161165
- name: .NET 9
162166
items:
163167
- name: Overview
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: "Breaking change - XsltSettings.EnableScript property is obsolete"
3+
description: "Learn about the breaking change in .NET 10 where XsltSettings.EnableScript property is marked as obsolete."
4+
ms.date: 01/14/2025
5+
ai-usage: ai-assisted
6+
ms.custom: https://github.com/dotnet/docs/issues/47504
7+
---
8+
9+
# XsltSettings.EnableScript property is obsolete
10+
11+
The <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> property is now marked as obsolete with diagnostic ID `SYSLIB0062`. XSLT script blocks are supported only in .NET Framework and are not supported on .NET Core or .NET 5+.
12+
13+
## Version introduced
14+
15+
.NET 10 Preview 1
16+
17+
## Previous behavior
18+
19+
Previously, the <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> property could be set without any compiler warnings:
20+
21+
- When set to `false`: script blocks were skipped (expected behavior anyway)
22+
- When set to `true`: a <xref:System.PlatformNotSupportedException> was thrown at runtime because script compilation is not supported
23+
24+
```csharp
25+
using System.Xml.Xsl;
26+
27+
// No compiler warnings in previous versions
28+
XsltSettings settings = new XsltSettings();
29+
settings.EnableScript = true; // Would throw PlatformNotSupportedException at runtime
30+
```
31+
32+
## New behavior
33+
34+
Starting in .NET 10, the <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=nameWithType> property is marked as obsolete. Setting or accessing this property generates a compile-time warning `SYSLIB0062`.
35+
36+
```csharp
37+
using System.Xml.Xsl;
38+
39+
// Generates SYSLIB0062 warning
40+
XsltSettings settings = new XsltSettings();
41+
settings.EnableScript = true; // Warning: SYSLIB0062: XsltSettings.EnableScript is obsolete
42+
```
43+
44+
## Type of breaking change
45+
46+
This change can affect [source compatibility](../../categories.md#source-compatibility).
47+
48+
## Reason for change
49+
50+
The property was obsoleted to turn a runtime error into a build warning, providing better guidance for migration. Since XSLT script blocks are not supported on modern .NET implementations, this property had no legitimate use case and would only result in runtime exceptions when set to `true`.
51+
52+
## Recommended action
53+
54+
Call sites should be reviewed for any assumptions made about the behavior of this property. References to the property can most likely be removed since the property did not truly enable script blocks on modern .NET.
55+
56+
Remove any references to `EnableScript` in your code:
57+
58+
```csharp
59+
// Before
60+
XsltSettings settings = new XsltSettings();
61+
settings.EnableScript = true; // Remove this line
62+
63+
// After
64+
XsltSettings settings = new XsltSettings();
65+
// No need to set EnableScript
66+
```
67+
68+
If you need to create XSLT settings with document function enabled but script disabled (which is the default behavior), use:
69+
70+
```csharp
71+
XsltSettings settings = new XsltSettings(enableDocumentFunction: true, enableScript: false);
72+
// Or simply use XsltSettings.Default which has EnableScript = false
73+
XsltSettings settings = XsltSettings.Default;
74+
```
75+
76+
## Affected APIs
77+
78+
- <xref:System.Xml.Xsl.XsltSettings.EnableScript?displayProperty=fullName>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ f1_keywords:
1919

2020
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).
2121

22+
> [!NOTE]
23+
> Starting in .NET 10, the <xref:System.Xml.Xsl.XsltSettings.EnableScript%2A> property is marked as obsolete and generates warning SYSLIB0062. Setting this property to `false` explicitly is no longer necessary since script execution is not supported on .NET Core or .NET 5+.
24+
2225
## Rule description
2326

2427
**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.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ The <xref:System.Xml.Xsl.XslCompiledTransform> class supports embedded scripts u
1616

1717
## 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 are not supported on .NET Core or .NET 5+, this property has no effect and setting it to `true` will throw a <xref:System.PlatformNotSupportedException> at runtime.
2023
2124
> [!NOTE]
2225
> XSLT scripting should be enabled only if you require script support and you are working in a fully trusted environment.

0 commit comments

Comments
 (0)