From 3a3c8213105dc29876b111a1cf0095504519e0b2 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 19 Oct 2021 16:43:40 -0700 Subject: [PATCH 1/2] xnodereader.getattribute breaking change --- docs/core/compatibility/6.0.md | 1 + .../6.0/xnodereader-getattribute.md | 39 +++++++++++++++++++ docs/core/compatibility/toc.yml | 4 ++ 3 files changed, 44 insertions(+) create mode 100644 docs/core/compatibility/core-libraries/6.0/xnodereader-getattribute.md diff --git a/docs/core/compatibility/6.0.md b/docs/core/compatibility/6.0.md index cc7f28f18408c..31c87fcc2d553 100644 --- a/docs/core/compatibility/6.0.md +++ b/docs/core/compatibility/6.0.md @@ -63,6 +63,7 @@ If you're migrating an app to .NET 6, the breaking changes listed here might aff | [System.Security.SecurityContext is marked obsolete](core-libraries/6.0/securitycontext-obsolete.md) | ✔️ | ❌ | RC 1 | | [Task.FromResult may return singleton](core-libraries/6.0/task-fromresult-returns-singleton.md) | ❌ | ✔️ | Preview 1 | | [Unhandled exceptions from a BackgroundService](core-libraries/6.0/hosting-exception-handling.md) | ✔️ | ❌ | Preview 4 | +| [XNodeReader.GetAttribute behavior for invalid index](core-libraries/6.0/xnodereader-getattribute.md) | | | Preview 2 | ## Cryptography diff --git a/docs/core/compatibility/core-libraries/6.0/xnodereader-getattribute.md b/docs/core/compatibility/core-libraries/6.0/xnodereader-getattribute.md new file mode 100644 index 0000000000000..6f2ddde18b3a3 --- /dev/null +++ b/docs/core/compatibility/core-libraries/6.0/xnodereader-getattribute.md @@ -0,0 +1,39 @@ +--- +title: "Breaking change: XNodeReader.GetAttribute and invalid indices" +description: Learn about the .NET 6.0 breaking change where XNodeReader.GetAttribute now throws an exception for an invalid index. +ms.date: 10/19/2021 +--- +# XNodeReader.GetAttribute behavior for invalid index + +`XNodeReader` is an internal class, but it's accessible through the class if you call . All implementations except `XNodeReader` threw an for an invalid index in the method. With this change, `XNodeReader.GetAttribute(int)` now also throws an for an invalid index. + +## Old behavior + +`XNodeReader.GetAttribute(int)` returned `null` if the index was invalid. + +## New behavior + +`XNodeReader.GetAttribute(int)` throws an if the index is invalid. + +## Version introduced + +6.0 Preview 2 + +## Type of breaking change + +This change can affect [source compatibility](../../categories.md#source-compatibility). + +## Reason for change + +`XmlReader.GetAttribute(int)` is well documented, and `XNodeReader` was not behaving as documented. It's behavior for invalid indices was also inconsistent with other implementations. + +## Recommended action + +To avoid an invalid index: + +- Call to retrieve the number of attributes in the current node. +- Then, pass a value of range `0..XmlReader.AttributeCount-1` to . + +## Affected APIs + +- diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index aa9ab64e63ec5..7e7cc6ea94c95 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -111,6 +111,8 @@ items: href: core-libraries/6.0/task-fromresult-returns-singleton.md - name: Unhandled exceptions from a BackgroundService href: core-libraries/6.0/hosting-exception-handling.md + - name: XNodeReader.GetAttribute behavior for invalid index + href: core-libraries/6.0/xnodereader-getattribute.md - name: Cryptography items: - name: CreateEncryptor methods throw exception for incorrect feedback size @@ -647,6 +649,8 @@ items: href: core-libraries/6.0/task-fromresult-returns-singleton.md - name: Unhandled exceptions from a BackgroundService href: core-libraries/6.0/hosting-exception-handling.md + - name: XNodeReader.GetAttribute behavior for invalid index + href: core-libraries/6.0/xnodereader-getattribute.md - name: .NET 5 items: - name: Assembly-related API changes for single-file publishing From b6cc735816c98caae9e3de3acbde9219cbaf6d64 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 19 Oct 2021 16:46:17 -0700 Subject: [PATCH 2/2] fill out table --- docs/core/compatibility/6.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/compatibility/6.0.md b/docs/core/compatibility/6.0.md index 31c87fcc2d553..7d20175668bc0 100644 --- a/docs/core/compatibility/6.0.md +++ b/docs/core/compatibility/6.0.md @@ -63,7 +63,7 @@ If you're migrating an app to .NET 6, the breaking changes listed here might aff | [System.Security.SecurityContext is marked obsolete](core-libraries/6.0/securitycontext-obsolete.md) | ✔️ | ❌ | RC 1 | | [Task.FromResult may return singleton](core-libraries/6.0/task-fromresult-returns-singleton.md) | ❌ | ✔️ | Preview 1 | | [Unhandled exceptions from a BackgroundService](core-libraries/6.0/hosting-exception-handling.md) | ✔️ | ❌ | Preview 4 | -| [XNodeReader.GetAttribute behavior for invalid index](core-libraries/6.0/xnodereader-getattribute.md) | | | Preview 2 | +| [XNodeReader.GetAttribute behavior for invalid index](core-libraries/6.0/xnodereader-getattribute.md) | ✔️ | ❌ | Preview 2 | ## Cryptography