From 23135c3db60a2bb3e41dc09d0dd5c16616235b27 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Tue, 19 Aug 2025 08:22:59 -0700 Subject: [PATCH 1/4] remove broken lins (#11705) --- .../DisplayFormatAttribute.xml | 7 +----- xml/System.Web.DynamicData/DynamicControl.xml | 6 ----- xml/System.Web.DynamicData/DynamicField.xml | 3 --- .../DynamicQueryStringParameter.xml | 4 ---- xml/System.Web.DynamicData/MetaModel.xml | 23 ------------------- 5 files changed, 1 insertion(+), 42 deletions(-) diff --git a/xml/System.ComponentModel.DataAnnotations/DisplayFormatAttribute.xml b/xml/System.ComponentModel.DataAnnotations/DisplayFormatAttribute.xml index d86a462100e..0df707a8673 100644 --- a/xml/System.ComponentModel.DataAnnotations/DisplayFormatAttribute.xml +++ b/xml/System.ComponentModel.DataAnnotations/DisplayFormatAttribute.xml @@ -52,18 +52,15 @@ When you apply this attribute to a data field, you must follow the guidelines for the use of the attributes. For more information, see [ASP.NET Dynamic Data Guidelines](/previous-versions/aspnet/cc668215(v=vs.100)). ## Examples - See an online example of this feature: [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.ComponentModel.DataAnnotations.DisplayFormatAttribute). - The following example shows how to use the to customize formatting for a data field. The example performs the following steps: +The following example shows how to use the to customize formatting for a data field. The example performs the following steps: - Implements a metadata partial class and an associated metadata class. - In the associated metadata class, it applies the attribute to specify the following results: - Display the text "[Null]" when a data field is empty. - - Display currency data in locale specific currency format. - - Display date information in short format (mm/dd/yy). This format also applies in edit mode. :::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.DisplayFormatAttribute/CS/product.cs" id="Snippet1"::: @@ -72,9 +69,7 @@ To compile the example, you need the following: - Any edition of Visual Studio 2010 or later. - - The AdventureWorksLT sample database. For information about how to download and install the SQL Server sample database, see [Microsoft SQL Server Product Samples: Database](https://github.com/Microsoft/sql-server-samples/releases) on GitHub. Make sure that you install the correct version of the sample database for the version of SQL Server that you are running. - - A data-driven Web site. This enables you to create a data context for the database and the class that contains the data field to customize. For more information, see `Walkthrough: Creating a New Dynamic Data Web Site using Scaffolding`. ]]> diff --git a/xml/System.Web.DynamicData/DynamicControl.xml b/xml/System.Web.DynamicData/DynamicControl.xml index 152c3f0f90f..20f9da5e91c 100644 --- a/xml/System.Web.DynamicData/DynamicControl.xml +++ b/xml/System.Web.DynamicData/DynamicControl.xml @@ -102,10 +102,7 @@ ``` - - ## Examples - See a run-time code example of this feature: [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.Web.DynamicData.DynamicControl). The following example demonstrates how to use the control in a control to display, insert, delete and edit values from a database table. It is important to notice that in order to make the insert operation to work, the property of the `rowguid` and `ModifiedDate` columns are set to `true`. @@ -844,10 +841,7 @@ The field template that you specify using the property is specific to this instance of the control. You can also change the field template used by a data field across the entire application by applying the to your data model. Setting the property overrides the metadata applied to the data model. For more information about metadata attributes, see [ASP.NET Dynamic Data](https://msdn.microsoft.com/library/78c7fcd7-5f38-46a0-a4bc-48eff3c8a512). - - ## Examples - See a run-time code example of this feature: [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.Web.DynamicData.DynamicControl.UIHint). The following example shows how you can specify a data field to use a different field template to render its contents. The second example shows the custom field template specified by the property. diff --git a/xml/System.Web.DynamicData/DynamicField.xml b/xml/System.Web.DynamicData/DynamicField.xml index ce36c47d2b6..d8ed588482a 100644 --- a/xml/System.Web.DynamicData/DynamicField.xml +++ b/xml/System.Web.DynamicData/DynamicField.xml @@ -158,10 +158,7 @@ ``` - - ## Examples - See a run-time code example of this feature: [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.Web.DynamicData.DynamicField). The following example demonstrates how to use the object in a control to display and edit values from a database table. diff --git a/xml/System.Web.DynamicData/DynamicQueryStringParameter.xml b/xml/System.Web.DynamicData/DynamicQueryStringParameter.xml index 83cd0f3a92d..4abbee41253 100644 --- a/xml/System.Web.DynamicData/DynamicQueryStringParameter.xml +++ b/xml/System.Web.DynamicData/DynamicQueryStringParameter.xml @@ -30,10 +30,6 @@ In order to use the class, you must add a control to the page and you must register the data-bound control with the control by using the method. - See a run-time code example of this feature: [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.Web.DynamicData.DynamicQueryStringParameter). - - - ## Examples The following example shows how to use the object as filter when displaying data in a control. The control contains a object that creates a link that sets the query string value by using the foreign key value. diff --git a/xml/System.Web.DynamicData/MetaModel.xml b/xml/System.Web.DynamicData/MetaModel.xml index 324d119fc43..8bd6b25f2ac 100644 --- a/xml/System.Web.DynamicData/MetaModel.xml +++ b/xml/System.Web.DynamicData/MetaModel.xml @@ -26,15 +26,11 @@ In Visual Studio, you can generate data-model types by using the **LINQ to SQL Classes** template or the **ADO.NET Entity Data Model** template. These templates use the Object Relational Designer (O/R Designer) for the LINQ to SQL model, or the ADO.NET Entity Data Model Designer (Entity Designer) for the Entity Framework model. - - ## Examples The following example shows how to use type to perform the following tasks in order to use automatic scaffolding in an ASP.NET Web site: - Get the data model for the default data context. - - Get the data model for a specified data context. - - Evaluate the routing path (determine the URL) for a specified table. The example consists of a page and its code-behind file. @@ -50,11 +46,8 @@ To compile the example, you need the following: - Visual Studio 2010 or Visual Web Developer 2010 Express. - - A Dynamic Data Web site. For more information, see [Walkthrough: Creating a New Dynamic Data Web Site Using Scaffolding](https://msdn.microsoft.com/library/1564aef2-9103-436a-9806-c8ad7abd616a). - See a run-time code example of this feature: [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.Web.DynamicData.MetaModel). - ]]> Can be thrown by any method if there has been a data context registration error. @@ -362,10 +355,6 @@ ## Remarks The route is determined by the combination of the table name and action. - [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.Web.DynamicData.MetaModel&spage=PathModel.aspx) an online example of this feature. - - - ## Examples The following example shows how to use the method to evaluate the routing path (determine the URL) for a specified table. For a complete example, see . @@ -432,15 +421,10 @@ ## Remarks The object that is returned by the overloaded methods contains the metadata information that is associated with the specified table. - [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.Web.DynamicData.MetaModel&spage=GetTable.aspx) an online example of this feature. - - - ## Examples The following example shows how to use the overloaded methods to perform the following tasks: - Get the object for the specified table. - - Access the metadata information that is contained by the object. The example consists of a page and its code-behind file. @@ -485,8 +469,6 @@ ## Remarks The name uniquely identifies a table in the data model and is used to generate the related URL for routing. - - ## Examples The following example shows how to use the method to obtain the metadata for the specified table. For a complete example, see . @@ -866,15 +848,10 @@ ## Remarks The collection contains all the tables in the data model, which includes the tables that are not visible (are not part of Dynamic Data scaffolding). - [Run](https://go.microsoft.com/fwlink/?LinkId=120736&sref=System.Web.DynamicData.MetaModel&spage=TablesMenu.aspx) an online example of this feature. - - - ## Examples The following example shows how to use the and properties to perform the following tasks: - Get a collection of all the tables in a data model and show them in a `GridView` control. - - Get a collection of the visible tables in a data model and show them in a `GridView` control. The example consists of a page and its code-behind file. From c2547a387ce34a3ea13c56a15a99aa64ef408699 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:35:18 +0000 Subject: [PATCH 2/4] Initial plan From 13c709f07670339cb3dc02a99743b8e372d6e28f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 19 Aug 2025 20:44:52 +0000 Subject: [PATCH 3/4] Update Encoding documentation to clarify GetEncoding(0) and Default behavior differences Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com> --- xml/System.Text/CodePagesEncodingProvider.xml | 26 ++++++++- xml/System.Text/Encoding.xml | 56 +++++++++++++++---- 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/xml/System.Text/CodePagesEncodingProvider.xml b/xml/System.Text/CodePagesEncodingProvider.xml index debf149416f..0c8a549b51d 100644 --- a/xml/System.Text/CodePagesEncodingProvider.xml +++ b/xml/System.Text/CodePagesEncodingProvider.xml @@ -75,6 +75,15 @@ After an object is registered, the encodings that it supports are available by calling the overloads of ; you should not call the overloads. +## Impact on Default Encoding Behavior + +Registering also affects the behavior of when called with a `codepage` argument of `0`: + +- **On Windows**: Returns the encoding that matches the system's active code page, which is the same behavior as in .NET Framework. +- **On non-Windows platforms**: Still returns UTF-8, maintaining cross-platform consistency. + +Without any encoding provider registered, with `codepage` 0 returns UTF-8 on all platforms in .NET Core and later versions. + ]]> @@ -154,7 +163,22 @@ The .NET Framework supports a large number of character encodings and code pages The code page identifier of the preferred encoding that the encoding provider might support. Returns the encoding associated with the specified code page identifier. The encoding associated with the specified code page identifier, or if the provider does not support the requested codepage encoding. - To be added. + + : + +- **On Windows**: Returns the encoding that matches the system's active code page, providing the same behavior as .NET Framework. +- **On non-Windows platforms**: Returns `null`, allowing to fall back to its default UTF-8 behavior. + +For all other supported code page identifiers, this method returns the corresponding encoding if it's available from the code pages encoding provider, or `null` if the code page is not supported. + + ]]> + diff --git a/xml/System.Text/Encoding.xml b/xml/System.Text/Encoding.xml index 0d9357ed830..1d1c7935e07 100644 --- a/xml/System.Text/Encoding.xml +++ b/xml/System.Text/Encoding.xml @@ -985,7 +985,23 @@ The returned 's and Gets the default encoding for this .NET implementation. The default encoding for this .NET implementation. - For more information about this API, see Supplemental API remarks for Encoding.Default. + + property varies between different .NET implementations: + +- **In .NET Framework**: Returns the encoding that corresponds to the system's active code page. This is the same encoding returned by when called with a `codepage` argument of `0`. + +- **In .NET Core and later versions**: Always returns a object. This behavior was changed to encourage the use of Unicode encodings for better cross-platform compatibility and data integrity. + +For the most consistent results across different platforms and .NET implementations, consider using a specific Unicode encoding such as UTF-8 directly instead of relying on the default encoding. You can obtain UTF-8 encoding by calling or with "utf-8". + +For more information about this API, see Supplemental API remarks for Encoding.Default. + + ]]> + @@ -3531,13 +3547,19 @@ The returned 's and method returns any additional encodings that are made available by registering an object. If the same encoding has been registered by multiple objects, this method returns the last one registered. -You can also supply a value of 0 for the `codepage` argument. Its precise behavior depends on whether any encodings have been made available by registering an object: +You can also supply a value of 0 for the `codepage` argument. The behavior varies between .NET Framework and .NET Core and later versions: + +**In .NET Framework**: Always returns the encoding that corresponds to the system's active code page in Windows. This is the same encoding returned by the property. -- If one or more encoding providers have been registered, it returns the encoding of the last registered provider that has chosen to return a encoding when the method is passed a `codepage` argument of 0. +**In .NET Core and later versions**: The behavior depends on the encoding configuration of the application: -- On .NET Framework, if no encoding provider has been registered, if the is the registered encoding provider, or if no registered encoding provider handles a `codepage` value of 0, it returns the operating system's active code page. To determine the active code page on Windows systems, call the Windows [GetACP](/windows/win32/api/winnls/nf-winnls-getacp) function from .NET Framework. +- **No encoding provider registered**: Returns a , same as . -- On .NET Core, if no encoding provider has been registered or if no registered encoding provider handles a `codepage` value of 0, it returns the . +- ** registered**: + - On **Windows**, returns the encoding that matches the system's active code page (same as .NET Framework behavior). + - On **non-Windows platforms**, always returns a . + +- **A different provider registered**: The behavior is determined by that provider. Consult its documentation for details. If multiple providers are registered, the method returns the encoding from the last registered provider that handles a `codepage` argument of 0. > [!NOTE] > - Some unsupported code pages cause an to be thrown, whereas others cause a . Therefore, your code must catch all exceptions indicated in the Exceptions section. @@ -3731,13 +3753,19 @@ In .NET Framework, the method relies In addition to the encodings that are natively available on .NET Core or that are intrinsically supported on a specific platform version of .NET Framework, the method returns any additional encodings that are made available by registering an object. If the same encoding has been registered by multiple objects, this method returns the last one registered. -You can also supply a value of 0 for the `codepage` argument. Its precise behavior depends on whether any encodings have been made available by registering an object: +You can also supply a value of 0 for the `codepage` argument. The behavior varies between .NET Framework and .NET Core and later versions: + +**In .NET Framework**: Always returns the encoding that corresponds to the system's active code page in Windows. This is the same encoding returned by the property. -- If one or more encoding providers have been registered, it returns the encoding of the last registered provider that has chosen to return a encoding when the method is passed a `codepage` argument of 0. +**In .NET Core and later versions**: The behavior depends on the encoding configuration of the application: -- On .NET Framework, if no encoding provider has been registered, if the is the registered encoding provider, or if no registered encoding provider handles a `codepage` value of 0, it returns the active code page. +- **No encoding provider registered**: Returns a , same as . -- On .NET Core, if no encoding provider has been registered or if no registered encoding provider handles a `codepage` value of 0, it returns the encoding. +- ** registered**: + - On **Windows**, returns the encoding that matches the system's active code page (same as .NET Framework behavior). + - On **non-Windows platforms**, always returns a . + +- **A different provider registered**: The behavior is determined by that provider. Consult its documentation for details. If multiple providers are registered, the method returns the encoding from the last registered provider that handles a `codepage` argument of 0. > [!NOTE] > The ANSI code pages can be different on different computers and can change on a single computer, leading to data corruption. For this reason, if the active code page is an ANSI code page, encoding and decoding data using the default code page returned by `Encoding.GetEncoding(0)` is not recommended. For the most consistent results, you should use Unicode, such as UTF-8 (code page 65001) or UTF-16, instead of a specific code page. @@ -5296,11 +5324,15 @@ The goal is to save this file, then open and decode it as a binary stream. ## Remarks The method allows you to register a class derived from that makes character encodings available on a platform that does not otherwise support them. Once the encoding provider is registered, the encodings that it supports can be retrieved by calling any overload. If there are multiple encoding providers, the method attempts to retrieve a specified encoding from each provider starting with the one most recently registered. -Registering an encoding provider by using the method also modifies the behavior of the [Encoding.GetEncoding(Int32)]() and [EncodingProvider.GetEncoding(Int32, EncoderFallback, DecoderFallback)](xref:System.Text.Encoding.GetEncoding(System.Int32,System.Text.EncoderFallback,System.Text.DecoderFallback)) methods when passed an argument of `0`: +Registering an encoding provider by using the method also affects the behavior of when passed an argument of `0`. This is particularly important in .NET Core and later versions where the default behavior for with `codepage` 0 is to return UTF-8: + +- **If the registered provider is **: + - On **Windows**, with `codepage` 0 returns the encoding that matches the system's active code page (same as .NET Framework behavior). + - On **non-Windows platforms**, it still returns UTF-8. -- If the registered provider is the , the method returns the encoding that matches the system active code page when running on the Windows operating system. +- **If a custom encoding provider is registered**: The provider can choose which encoding to return when is passed an argument of `0`. The provider can also choose to not handle this case by returning `null` from its method, in which case the default UTF-8 behavior is used. -- A custom encoding provider can choose which encoding to return when either of these method overloads is passed an argument of `0`. The provider can also choose to not return an encoding by having the method return `null`. +If multiple providers are registered, attempts to retrieve the encoding from the most recently registered provider first. Starting with .NET Framework 4.6, .NET Framework includes one encoding provider, , that makes the encodings available that are present in the full .NET Framework but are not available in the Universal Windows Platform. By default, the Universal Windows Platform only supports the Unicode encodings, ASCII, and code page 28591. From a47f9940f935186ec270e0bba9f2eb746fc6d896 Mon Sep 17 00:00:00 2001 From: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com> Date: Tue, 19 Aug 2025 16:04:54 -0700 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- xml/System.Text/CodePagesEncodingProvider.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xml/System.Text/CodePagesEncodingProvider.xml b/xml/System.Text/CodePagesEncodingProvider.xml index 0c8a549b51d..4100c51f09d 100644 --- a/xml/System.Text/CodePagesEncodingProvider.xml +++ b/xml/System.Text/CodePagesEncodingProvider.xml @@ -75,14 +75,14 @@ After an object is registered, the encodings that it supports are available by calling the overloads of ; you should not call the overloads. -## Impact on Default Encoding Behavior +### Impact on default encoding behavior -Registering also affects the behavior of when called with a `codepage` argument of `0`: +Registering also affects the behavior of when called with a `codepage` argument of `0` in .NET (Core): -- **On Windows**: Returns the encoding that matches the system's active code page, which is the same behavior as in .NET Framework. -- **On non-Windows platforms**: Still returns UTF-8, maintaining cross-platform consistency. +- On Windows, `GetEncoding(0)` returns the encoding that matches the system's active code page, which is the same behavior as in .NET Framework. +- On non-Windows platforms, `GetEncoding(0)` returns UTF-8, maintaining cross-platform consistency. -Without any encoding provider registered, with `codepage` 0 returns UTF-8 on all platforms in .NET Core and later versions. +When no encoding provider is registered, `GetEncoding(0)` returns UTF-8 on all platforms in .NET Core and later versions. ]]>