From d7492465023b4a887089003c01ac702799adc67c Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:45:29 -0800 Subject: [PATCH 1/6] Add link to trimming options (#44099) --- docs/core/compatibility/serialization/8.0/publishtrimmed.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/core/compatibility/serialization/8.0/publishtrimmed.md b/docs/core/compatibility/serialization/8.0/publishtrimmed.md index b318cbb245b53..96f1a310d5b5f 100644 --- a/docs/core/compatibility/serialization/8.0/publishtrimmed.md +++ b/docs/core/compatibility/serialization/8.0/publishtrimmed.md @@ -49,3 +49,7 @@ However, if you must use reflection, you can revert to the original behavior by ## Affected APIs N/A + +## See also + +- [Trimming options: Enable trimming](../../../deploying/trimming/trimming-options.md#enable-trimming) From 53e50f71c44b02bd10da8bfd7b61cbac28f88c48 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:46:27 -0800 Subject: [PATCH 2/6] add note about option format (#44098) --- .../code-analysis/style-rules/ide0079.md | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/fundamentals/code-analysis/style-rules/ide0079.md b/docs/fundamentals/code-analysis/style-rules/ide0079.md index 37097baee816d..0f42cc6d84d2d 100644 --- a/docs/fundamentals/code-analysis/style-rules/ide0079.md +++ b/docs/fundamentals/code-analysis/style-rules/ide0079.md @@ -1,7 +1,7 @@ --- title: "IDE0079: Remove unnecessary suppression" description: "Learn about code analysis rule IDE0079: Remove unnecessary suppression" -ms.date: 03/23/2023 +ms.date: 12/27/2024 f1_keywords: - IDE0079 - dotnet_remove_unnecessary_suppression_exclusions @@ -71,15 +71,23 @@ class C2 Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). +> [!NOTE] +> Setting a severity in the format `option_name = value:severity` doesn't apply to the `dotnet_remove_unnecessary_suppression_exclusions` option and should be avoided. Instead, specify the severity using a separate entry, for example: +> +> ```ini +> dotnet_remove_unnecessary_suppression_exclusions = none +> dotnet_diagnostic.IDE0079.severity = warning +> ``` + ### dotnet_remove_unnecessary_suppression_exclusions -| Property | Value | Description | -| ------------------------ | ------------------------------------------------------------------------ | ---------------------------------------------- | -| **Option name** | dotnet_remove_unnecessary_suppression_exclusions | | -| **Option values** | `,` separated list of rule IDs or categories (prefixed with `category:`) | Excludes suppressions for the listed rules | -| | `all` | Disables the rule (all rule IDs excluded) | -| | `none` | Enables the rule for all rules (no exclusions) | -| **Default option value** | `none` | | +| Property | Value | Description | +|--------------------------|--------------------------------------------------|------------------------------------------------| +| **Option name** | dotnet_remove_unnecessary_suppression_exclusions | | +| **Option values** | Comma-separated list of rule IDs or categories (prefixed with `category:`) | Excludes suppressions for the listed rules or categories | +| | `all` | Disables the rule (all rule IDs excluded) | +| | `none` | Enables the rule for all rules (no exclusions) | +| **Default option value** | `none` | | ```csharp using System.Diagnostics.CodeAnalysis; From cf3cc01788024bcaa2f50793726d1557f5c8e994 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:46:59 -0800 Subject: [PATCH 3/6] Update wording (#44096) --- docs/core/tools/dotnet-install-script.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/core/tools/dotnet-install-script.md b/docs/core/tools/dotnet-install-script.md index e5b36cf12196a..03488c9e51392 100644 --- a/docs/core/tools/dotnet-install-script.md +++ b/docs/core/tools/dotnet-install-script.md @@ -5,7 +5,8 @@ ms.date: 12/26/2024 --- # dotnet-install scripts reference -Note: The behavior of the install script has changed. It downloads .NET from new network locations. Please see [Critical: .NET Install links are changing](https://devblogs.microsoft.com/dotnet/critical-dotnet-install-links-are-changing/) for more information. +> [!NOTE] +> The behavior of the install script has changed. It downloads .NET from new network locations. For more information, see [Critical: .NET Install links are changing](https://devblogs.microsoft.com/dotnet/critical-dotnet-install-links-are-changing/). ## Name From 05a52e87061dd175e0bb97ee3681dc3bf4f60959 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Tue, 31 Dec 2024 19:48:02 +0100 Subject: [PATCH 4/6] Add missing dependencies in linux-alpine.md (#44113) * Add missing dependencies in linux-alpine.md This commit adds icu-libs and icu-data-full to the list of required dependencies on Alpine. There are required unless the app is running in globalization-invariant mode. See https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.16.0#ICU_data_split for more information about why both those packages need to be mentioned. * Fix broken link in linux-alpine.md --------- Co-authored-by: Andy (Steve) De George <67293991+adegeo@users.noreply.github.com> --- docs/core/install/linux-alpine.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/core/install/linux-alpine.md b/docs/core/install/linux-alpine.md index 170b994892069..f5ad983ddb4d6 100644 --- a/docs/core/install/linux-alpine.md +++ b/docs/core/install/linux-alpine.md @@ -76,6 +76,7 @@ When you install with a package manager, these libraries are installed for you. - libssl3 - libstdc++ - zlib +- icu-libs and icu-data-full (unless the .NET app is running in [globalization-invariant mode](../runtime-config/globalization.md#invariant-mode) - libgdiplus (if the .NET app requires the *System.Drawing.Common* assembly) Use the `apk add` command to install the dependencies. From 0b5b1e33f663699394212876731315e7d35c677f Mon Sep 17 00:00:00 2001 From: Raphael <51923061+RaphaelSantiago53@users.noreply.github.com> Date: Tue, 31 Dec 2024 20:50:57 +0200 Subject: [PATCH 5/6] Correct property and field names (#44097) --- docs/csharp/language-reference/keywords/value.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/language-reference/keywords/value.md b/docs/csharp/language-reference/keywords/value.md index 66237d7eb581a..8ffd134325913 100644 --- a/docs/csharp/language-reference/keywords/value.md +++ b/docs/csharp/language-reference/keywords/value.md @@ -9,7 +9,7 @@ helpviewer_keywords: --- # The `value` implicit parameter -The implicit parameter `value` is used in the `set` accessor in [property](../../programming-guide/classes-and-structs/properties.md) and [indexer](../../programming-guide/indexers/index.md) declarations. It's an input parameter of a method. The word `value` references the value that client code is attempting to assign to the property or indexer. In the following example, `TimePeriod2` has a property called `Name` that uses the `value` parameter to assign a new string to the backing field `name`. From the point of view of client code, the operation is written as a simple assignment. +The implicit parameter `value` is used in the `set` accessor in [property](../../programming-guide/classes-and-structs/properties.md) and [indexer](../../programming-guide/indexers/index.md) declarations. It's an input parameter of a method. The word `value` references the value that client code is attempting to assign to the property or indexer. In the following example, `TimePeriod2` has a property called `Seconds` that uses the `value` parameter to assign a new string to the backing field `_seconds`. From the point of view of client code, the operation is written as a simple assignment. :::code language="csharp" source="./snippets/PropertyAccessors.cs" id="GetSetExpressions"::: From f463647760766341e0ed2a110a21dd5f8be089eb Mon Sep 17 00:00:00 2001 From: Konstantin Lepeshenkov <5447190+scale-tone@users.noreply.github.com> Date: Tue, 31 Dec 2024 20:56:26 +0100 Subject: [PATCH 6/6] Fixed incorrect logic in XmlReader's example (#43799) (#44054) * Fixed incorrect logic in XmlReader's example (#43799) * Refactor XML streaming example in C# and VB * Format XML string for better readability * Remove unnecessary else statements in XML reader doc --------- Co-authored-by: Andy (Steve) De George <67293991+adegeo@users.noreply.github.com> --- .../linq/stream-xml-fragments-xmlreader.md | 208 +++++++----------- 1 file changed, 77 insertions(+), 131 deletions(-) diff --git a/docs/standard/linq/stream-xml-fragments-xmlreader.md b/docs/standard/linq/stream-xml-fragments-xmlreader.md index bc7312acae98c..cdaa877cb0323 100644 --- a/docs/standard/linq/stream-xml-fragments-xmlreader.md +++ b/docs/standard/linq/stream-xml-fragments-xmlreader.md @@ -27,163 +27,109 @@ The article [How to perform streaming transform of large XML documents](perform- This example creates a custom axis method. You can query it by using a LINQ query. The custom axis method `StreamRootChildDoc` can read a document that has a repeating `Child` element. ```csharp +using System.Xml; +using System.Xml.Linq; + static IEnumerable StreamRootChildDoc(StringReader stringReader) { - using (XmlReader reader = XmlReader.Create(stringReader)) + using XmlReader reader = XmlReader.Create(stringReader); + + reader.MoveToContent(); + + // Parse the file and display each of the nodes. + while (true) { - reader.MoveToContent(); - // Parse the file and display each of the nodes. - while (reader.Read()) + // If the current node is an element and named "Child" + if (reader.NodeType == XmlNodeType.Element && reader.Name == "Child") { - switch (reader.NodeType) - { - case XmlNodeType.Element: - if (reader.Name == "Child") { - XElement el = XElement.ReadFrom(reader) as XElement; - if (el != null) - yield return el; - } - break; - } + // Get the current node and advance the reader to the next + if (XNode.ReadFrom(reader) is XElement el) + yield return el; + } + else if (!reader.Read()) + break; } } -static void Main(string[] args) -{ - string markup = @" - - aaa - - - bbb - - - ccc - - "; - - IEnumerable grandChildData = - from el in StreamRootChildDoc(new StringReader(markup)) - where (int)el.Attribute("Key") > 1 - select (string)el.Element("GrandChild"); - - foreach (string str in grandChildData) { - Console.WriteLine(str); - } -} +string markup = """ + + + aaa + + + bbb + + + ccc + + + """; + +IEnumerable grandChildData = + from el in StreamRootChildDoc(new StringReader(markup)) + where (int)el.Attribute("Key") > 1 + select (string)el.Element("GrandChild"); + +foreach (string str in grandChildData) + Console.WriteLine(str); ``` ```vb -Module Module1 - Sub Main() - Dim markup = "" & - " " & - " aaa" & - " " & - " " & - " bbb" & - " " & - " " & - " ccc" & - " " & - "" - - Dim grandChildData = - From el In New StreamRootChildDoc(New IO.StringReader(markup)) - Where CInt(el.@Key) > 1 - Select el..Value - - For Each s In grandChildData - Console.WriteLine(s) - Next - End Sub -End Module - -Public Class StreamRootChildDoc - Implements IEnumerable(Of XElement) +Imports System.Xml - Private _stringReader As IO.StringReader - - Public Sub New(ByVal stringReader As IO.StringReader) - _stringReader = stringReader - End Sub - - Public Function GetEnumerator() As IEnumerator(Of XElement) Implements IEnumerable(Of XElement).GetEnumerator - Return New StreamChildEnumerator(_stringReader) - End Function +Module Module1 - Public Function GetEnumerator1() As IEnumerator Implements IEnumerable.GetEnumerator - Return Me.GetEnumerator() - End Function -End Class + Public Iterator Function StreamRootChildDoc(stringReader As IO.StringReader) As IEnumerable(Of XElement) + Using reader As XmlReader = XmlReader.Create(stringReader) + reader.MoveToContent() -Public Class StreamChildEnumerator - Implements IEnumerator(Of XElement) + ' Parse the file and display each of the nodes. + While True - Private _current As XElement - Private _reader As Xml.XmlReader - Private _stringReader As IO.StringReader + ' If the current node is an element and named "Child" + If reader.NodeType = XmlNodeType.Element And reader.Name = "Child" Then - Public Sub New(ByVal stringReader As IO.StringReader) - _stringReader = stringReader - _reader = Xml.XmlReader.Create(_stringReader) - _reader.MoveToContent() - End Sub + ' Get the current node and advance the reader to the next + Dim el As XElement = TryCast(XNode.ReadFrom(reader), XElement) - Public ReadOnly Property Current As XElement Implements IEnumerator(Of XElement).Current - Get - Return _current - End Get - End Property - - Public ReadOnly Property Current1 As Object Implements IEnumerator.Current - Get - Return Me.Current - End Get - End Property - - Public Function MoveNext() As Boolean Implements IEnumerator.MoveNext - While _reader.Read() - Select Case _reader.NodeType - Case Xml.XmlNodeType.Element - Dim el = TryCast(XElement.ReadFrom(_reader), XElement) - If el IsNot Nothing Then - _current = el - Return True + If (el IsNot Nothing) Then + Yield el End If - End Select - End While - Return False + ElseIf Not reader.Read() Then + Exit While + End If + + End While + End Using End Function - Public Sub Reset() Implements IEnumerator.Reset - _reader = Xml.XmlReader.Create(_stringReader) - _reader.MoveToContent() - End Sub + Sub Main() -#Region "IDisposable Support" + Dim markup = " + + aaa + + + bbb + + + ccc + + " - Private disposedValue As Boolean ' To detect redundant calls + Dim grandChildData = + From el In StreamRootChildDoc(New IO.StringReader(markup)) + Where CInt(el.@Key) > 1 + Select el..Value - ' IDisposable - Protected Overridable Sub Dispose(ByVal disposing As Boolean) - If Not Me.disposedValue Then - If disposing Then - _reader.Close() - End If - End If - Me.disposedValue = True - End Sub + For Each s In grandChildData + Console.WriteLine(s) + Next - Public Sub Dispose() Implements IDisposable.Dispose - Dispose(True) - GC.SuppressFinalize(Me) End Sub -#End Region - -End Class +End Module ``` This example produces the following output: