diff --git a/xml/System.Reflection.Metadata/MetadataStringComparer.xml b/xml/System.Reflection.Metadata/MetadataStringComparer.xml index 2ee106e9549..e661dd54a29 100644 --- a/xml/System.Reflection.Metadata/MetadataStringComparer.xml +++ b/xml/System.Reflection.Metadata/MetadataStringComparer.xml @@ -47,20 +47,21 @@ No allocation is performed unless both the handle argument and the value argumen Obtain instances using . A default-initialized instance is useless and behaves as a `null` reference. -The code is optimized so that there is no additional overhead in re-obtaining a comparer over assigning it to a local. That is to say that a construct like: +The code is optimized so that there is no additional overhead in reobtaining a comparer over assigning it to a local. That is to say that a construct like: -```cs +```csharp if (reader.StringComparer.Equals(typeDef.Namespace, "System") && reader.StringComparer.Equals(typeDef.Name, "Object") { /* found System.Object */ } ``` -is no less efficient than: -```cs +...is no less efficient than: + +```csharp var comparer = reader.StringComparer; -if (comparer.Equals(typeDef.Namespace, "System") && comparer.Equals(typeDef.Name, "Object") -{ +if (comparer.Equals(typeDef.Namespace, "System") && comparer.Equals(typeDef.Name, "Object") +{ /* found System.Object */ } ``` diff --git a/xml/System.Reflection/AssemblyName.xml b/xml/System.Reflection/AssemblyName.xml index c239bb3de0b..41c520abb9e 100644 --- a/xml/System.Reflection/AssemblyName.xml +++ b/xml/System.Reflection/AssemblyName.xml @@ -112,13 +112,10 @@ ## Remarks The object contains information about an assembly, which you can use to bind to that assembly. An assembly's identity consists of the following: -- Simple name. - -- Version number. - -- Cryptographic key pair. - -- Supported culture. +- Simple name. +- Version number. +- Cryptographic key pair. +- Supported culture. The simple name is typically the file name for the manifest file without its extension. The key pair includes a public and private key, used to create strong-name signatures for assemblies. @@ -146,13 +143,11 @@ To ensure that the names are constructed correctly, use the following properties: -- - -- - -- +- +- +- - You can also get the name by using the `/l` option with the [Gacutil.exe (Global Assembly Cache Tool)](/dotnet/framework/tools/gacutil-exe-gac-tool) + You can also get the name by using the `/l` option with the [Gacutil.exe (Global Assembly Cache Tool)](/dotnet/framework/tools/gacutil-exe-gac-tool). For a partially specified strong name, create an object using the parameterless constructor and set the name and public key. An assembly created using such an can be signed later using the Assembly Linker (Al.exe). @@ -174,18 +169,16 @@ The following example shows an for a simply named assembly with default culture. -``` +```txt ExampleAssembly, Culture="" ``` The following example shows a fully specified reference for a strongly named assembly with culture "en". -``` +```txt ExampleAssembly, Version=1.0.0.0, Culture=en, PublicKeyToken=a5d015c7d5a0b012 ``` - - ## Examples This example shows how to use various reflection classes to analyze the metadata contained in an assembly. @@ -812,7 +805,7 @@ Note: In .NET for Win ## Remarks The display name typically consists of the simple name, version number, supported culture, and public key. For example: -``` +```txt mylib, Version=1.2.1900.0, Culture=neutral, PublicKeyToken=a14f3033def15840 ``` diff --git a/xml/System.Reflection/AssemblyVersionAttribute.xml b/xml/System.Reflection/AssemblyVersionAttribute.xml index 8dc56d418b6..9880085f5fd 100644 --- a/xml/System.Reflection/AssemblyVersionAttribute.xml +++ b/xml/System.Reflection/AssemblyVersionAttribute.xml @@ -68,37 +68,37 @@ Specifies the version of the assembly being attributed. - attribute is used to assign a version number to an assembly. That version number is then stored with the assembly's metadata. - - The assembly version number is part of an assembly's identity and plays a key part in binding to the assembly and in version policy. The default version policy for the runtime is that applications run only with the versions they were built and tested with, unless overridden by explicit version policy in configuration files (the application configuration file, the publisher policy file, and the computer's administrator configuration file). See [Assemblies in .NET](/dotnet/standard/assembly/#assemblies-in-the-common-language-runtime) for more information. - + attribute is used to assign a version number to an assembly. That version number is then stored with the assembly's metadata. + + The assembly version number is part of an assembly's identity and plays a key part in binding to the assembly and in version policy. The default version policy for the runtime is that applications run only with the versions they were built and tested with, unless overridden by explicit version policy in configuration files (the application configuration file, the publisher policy file, and the computer's administrator configuration file). See [Assemblies in .NET](/dotnet/standard/assembly/#assemblies-in-the-common-language-runtime) for more information. + > [!NOTE] -> Version checking only occurs with strong-named assemblies. - - The version number has four parts, as follows: - - \.\.\.\ - +> Version checking only occurs with strong-named assemblies. + + The version number has four parts, as follows: + + \.\.\.\ + > [!IMPORTANT] -> All components of the version must be integers greater than or equal to 0. Metadata restricts the major, minor, build, and revision components for an assembly to a maximum value of - 1. If a component exceeds this value, a compilation error occurs. +> All components of the version must be integers greater than or equal to 0. Metadata restricts the major, minor, build, and revision components for an assembly to a maximum value of - 1. If a component exceeds this value, a compilation error occurs. - For example, `[assembly:AssemblyVersion("2.3.25.1")]` indicates 2 as the major version, 3 as the minor version, 25 as the build number, and 1 as the revision number. + For example, `[assembly:AssemblyVersion("2.3.25.1")]` indicates 2 as the major version, 3 as the minor version, 25 as the build number, and 1 as the revision number. -The attribute allows you to specify an asterisk (\*) in place of the build or revision number. A version number such as `[assembly:AssemblyVersion("1.2.*")]` specifies 1 as the major version and 2 as the minor version, and accepts the default build and revision numbers. A version number such as `[assembly:AssemblyVersion("1.2.15.*")]` specifies 1 as the major version, 2 as the minor version, and 15 as the build number, and accepts the default revision number. The default build number increments daily. The default revision number is the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2. If you specify an asterisk for the build number, you can't specify a revision number. +The attribute allows you to specify an asterisk (\*) in place of the build or revision number. A version number such as `[assembly:AssemblyVersion("1.2.*")]` specifies 1 as the major version and 2 as the minor version, and accepts the default build and revision numbers. A version number such as `[assembly:AssemblyVersion("1.2.15.*")]` specifies 1 as the major version, 2 as the minor version, and 15 as the build number, and accepts the default revision number. The default build number increments daily. The default revision number is the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2. If you specify an asterisk for the build number, you can't specify a revision number. -> [!IMPORTANT] +> [!IMPORTANT] > Use of the attribute that specifies an asterisk: > > - Makes the build outputs non-reproducible (see [Reproducible builds](https://reproducible-builds.org/)). If the project sets `Deterministic` build property to `true` an error `CS8357` is reported by the compiler. > - Might degrade build performance, as it prevents build from caching compiler outputs. > - Is incompatible with the [Edit & Continue](/visualstudio/debugger/edit-and-continue-visual-csharp) and [Hot Reload](/visualstudio/debugger/hot-reload) features. - + You can mitigate some of these issues by limiting the use of time-based versions to release builds using conditional compilation, like so: -``` +```csharp #if DEBUG [assembly: AssemblyVersion("1.0.0.0")] #else @@ -108,20 +108,20 @@ You can mitigate some of these issues by limiting the use of time-based versions A better approach to versioning is to derive the assembly or file version from the `HEAD` commit SHA (for git repositories). See, for example, [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning). - The assembly major and minor versions are used as the type library version number when the assembly is exported. Some COM hosts do not accept type libraries with the version number 0.0. Therefore, if you want to expose an assembly to COM clients, set the assembly version explicitly to 1.0 in the `AssemblyVersionAttribute` page for projects created outside Visual Studio 2005 and with no `AssemblyVersionAttribute` specified. Do this even when the assembly version is 0.0. All projects created in Visual Studio 2005 have a default assembly version of 1.0.*. - - To get the name of an assembly you have loaded, call on the assembly to get an , and then get the property. To get the name of an assembly you have not loaded, call from your client application to check the assembly version that your application uses. - - The attribute can only be applied once. Some Visual Studio project templates already include the attribute. In those projects, adding the attribute in code causes a compiler error. - - - -## Examples - The following example uses the attribute to assign a version number to an assembly. At compile time, this version information is stored with the assembly's metadata. At run time, the example retrieves the value of the property on a type found in the assembly to get a reference to the executing assembly, and it retrieves the assembly's version information from the property of the object returned by the method. - + The assembly major and minor versions are used as the type library version number when the assembly is exported. Some COM hosts do not accept type libraries with the version number 0.0. Therefore, if you want to expose an assembly to COM clients, set the assembly version explicitly to 1.0 in the `AssemblyVersionAttribute` page for projects created outside Visual Studio 2005 and with no `AssemblyVersionAttribute` specified. Do this even when the assembly version is 0.0. All projects created in Visual Studio 2005 have a default assembly version of 1.0.*. + + To get the name of an assembly you have loaded, call on the assembly to get an , and then get the property. To get the name of an assembly you have not loaded, call from your client application to check the assembly version that your application uses. + + The attribute can only be applied once. Some Visual Studio project templates already include the attribute. In those projects, adding the attribute in code causes a compiler error. + + + +## Examples + The following example uses the attribute to assign a version number to an assembly. At compile time, this version information is stored with the assembly's metadata. At run time, the example retrieves the value of the property on a type found in the assembly to get a reference to the executing assembly, and it retrieves the assembly's version information from the property of the object returned by the method. + :::code language="csharp" source="~/snippets/csharp/System/Version/Overview/example1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Version.Class/vb/example1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Version.Class/vb/example1.vb" id="Snippet6"::: + ]]> @@ -175,29 +175,29 @@ You can mitigate some of these issues by limiting the use of time-based versions The version number of the attributed assembly. Initializes a new instance of the class with the version number of the assembly being attributed. - Set assembly attributes diff --git a/xml/System.Reflection/EventInfo.xml b/xml/System.Reflection/EventInfo.xml index 020ac86d666..ef22c3ecd3e 100644 --- a/xml/System.Reflection/EventInfo.xml +++ b/xml/System.Reflection/EventInfo.xml @@ -575,7 +575,7 @@ Note: In method allows you to write code that assigns specific types to the type parameters of a generic method definition, thus creating a object that represents a particular constructed method. If the property of this object returns `true`, you can use it to invoke the method or to create a delegate to invoke the method. - Methods constructed with the method can be open, that is, some of their type arguments can be type parameters of enclosing generic types. You might use such open constructed methods when you generate dynamic assemblies. For example, consider the following C#, Visual Basic, and C++ code. + Methods constructed with the method can be open, that is, some of their type arguments can be type parameters of enclosing generic types. You might use such open constructed methods when you generate dynamic assemblies. For example, consider the following code. -``` +```csharp class C { T N(T t, U u) {...} @@ -1168,7 +1163,9 @@ class C return N(v, 42); } } +``` +```vb Class C Public Function N(Of T,U)(ByVal ta As T, ByVal ua As U) As T ... @@ -1177,17 +1174,6 @@ Class C Return N(Of V, Integer)(va, 42) End Function End Class - -ref class C -{ -private: - generic T N(T t, U u) {...} -public: - generic V M(V v) - { - return N(v, 42); - } -}; ``` The method body of `M` contains a call to method `N`, specifying the type parameter of `M` and the type . The property returns `false` for method `N`. The property returns `true`, so method `N` cannot be invoked. @@ -1199,17 +1185,12 @@ public: ## Examples The following code example demonstrates the properties and methods of that support the examination of generic methods. The example does the following: -- Defines a class that has a generic method. - -- Creates a that represents the generic method. - -- Displays properties of the generic method definition. - -- Assigns type arguments to the type parameters of the , and invokes the resulting constructed generic method. - -- Displays properties of the constructed generic method. - -- Retrieves the generic method definition from the constructed method and compares it to the original definition. +- Defines a class that has a generic method. +- Creates a that represents the generic method. +- Displays properties of the generic method definition. +- Assigns type arguments to the type parameters of the , and invokes the resulting constructed generic method. +- Displays properties of the constructed generic method. +- Retrieves the generic method definition from the constructed method and compares it to the original definition. :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringMethod/source.cs" id="Snippet1"::: diff --git a/xml/System.Runtime.CompilerServices/Unsafe.xml b/xml/System.Runtime.CompilerServices/Unsafe.xml index 7637a3a3238..c219ee8847c 100644 --- a/xml/System.Runtime.CompilerServices/Unsafe.xml +++ b/xml/System.Runtime.CompilerServices/Unsafe.xml @@ -62,7 +62,7 @@ Consider the following example, which reverses the elements within a `Span`. > [!NOTE] > These examples exist simply for demonstration purposes. In real-world applications, developers should instead use helper functions like , which are better optimized than even these examples. -```cs + ```csharp // A safe, verifiable way to reverse a Span. static void Reverse(Span span) { @@ -79,7 +79,7 @@ static void Reverse(Span span) This method is fully type-safe and the .NET runtime may insert bounds checks to help enforce safety. However, low-level library authors may want to suppress .NET's normal safety checks in order to improve the performance of their own code. Such developers would typically rely on static analysis tools or their own code reviews to help enforce correctness. The `Unsafe` APIs allow a developer to rewrite this code using unverifiable constructs, as the following example shows. -```cs + ```csharp // A correct but unverifiable way to reverse a Span. static void Reverse(Span span) { @@ -639,7 +639,7 @@ The behavior of `Unsafe.As(o)` is only well-defined if the typical "safe" cas To help enforce correct usage, developers might consider using a standard cast or a debug-only assert in their code, as shown in the following examples. -```cs + ```csharp void ReinterpretCastAndUse_Sample1(object o) { // Assume that we know through some other means that 'o' is a string, @@ -739,7 +739,7 @@ This API is conceptually similar to C++'s `reinterpret_cast<>`. It is the caller Only the managed pointer is reinterpreted. The referenced value itself will remain unchanged. Consider the following example. -```cs + ```csharp int[] intArray = new int[] { 0x1234_5678 }; // a 1-element array ref int refToInt32 = ref intArray[0]; // managed pointer to first Int32 in array ref short refToInt16 = ref Unsafe.As(ref refToInt32); // reinterpret as managed pointer to Int16 @@ -969,7 +969,7 @@ This API is conceptually similar to C++'s `const_cast<>`. It is the caller's res `AsRef` is typically used for passing a readonly reference into methods like , which accept mutable managed pointers as arguments. Consider the following example. -```cs + ```csharp int ComputeSumOfElements(ref int refToFirstElement, nint numElements) { int sum = 0; @@ -982,7 +982,7 @@ int ComputeSumOfElements(ref int refToFirstElement, nint numElements) If the input parameter is `ref readonly int refToFirstElement` instead of `ref int refToFirstElement`, the previous example will not compile, since readonly references cannot be used as arguments to `Add`. Instead, `AsRef` can be used to remove the immutability constraint and allow compilation to succeed, as shown in the following example. -```cs + ```csharp int ComputeSumOfElements(ref readonly int refToFirstElement, nint numElements) { int sum = 0; @@ -1212,7 +1212,7 @@ Both `destination` and `source` are assumed to be properly aligned for pointers This method is roughly equivalent to the following code. -```cs + ```csharp static void Copy(void* destination, ref T source) { T data = source; // dereference source @@ -1294,7 +1294,7 @@ Both `destination` and `source` are assumed to be properly aligned for pointers This method is roughly equivalent to the following code. -```cs + ```csharp static void Copy(ref T destination, void* source) { T data = *(T*)source; // reinterpret cast source as T* and dereference @@ -2376,7 +2376,7 @@ This API corresponds to the `sizeof` opcode. If `T` is a reference type, the ret This method is typically used to avoid double-initialization when initializing union-type structs. Consider the following example, which produces a C# compiler error. -```cs + ```csharp using System; using System.Runtime.InteropServices; @@ -2401,7 +2401,7 @@ This error occurs because the compiler expects _all_ fields of the struct to be One way to avoid this compiler error is to ensure the entire struct is zero-initialized before individual fields are set, as shown in the following example. -```cs + ```csharp // This sample compiles successfully. public static MyUnionStruct MyMethod() { MyUnionStruct value = default; // the struct is now guaranteed assigned @@ -2412,7 +2412,7 @@ public static MyUnionStruct MyMethod() { If you want to avoid the initial zero-initialization, you can call the `SkipInit` method can be used to suppress the compiler warning. -```cs + ```csharp using System.Runtime.CompilerServices; // This sample also compiles successfully. diff --git a/xml/System.Runtime.DurableInstancing/InstancePersistenceContext.xml b/xml/System.Runtime.DurableInstancing/InstancePersistenceContext.xml index 2eb307ab602..00a13e6140c 100644 --- a/xml/System.Runtime.DurableInstancing/InstancePersistenceContext.xml +++ b/xml/System.Runtime.DurableInstancing/InstancePersistenceContext.xml @@ -379,21 +379,24 @@ diff --git a/xml/System.Runtime.InteropServices.WindowsRuntime/ReturnValueNameAttribute.xml b/xml/System.Runtime.InteropServices.WindowsRuntime/ReturnValueNameAttribute.xml index 3cb61f51f1a..1b90bd744fb 100644 --- a/xml/System.Runtime.InteropServices.WindowsRuntime/ReturnValueNameAttribute.xml +++ b/xml/System.Runtime.InteropServices.WindowsRuntime/ReturnValueNameAttribute.xml @@ -52,7 +52,6 @@ Public Shared Function ComputeAverage( _ ByRef maxValue As Integer) As Integer … End Function - ``` When you call the function from JavaScript, you can access the return value by its default name (`value`): @@ -62,7 +61,6 @@ var data = [5, 13, 23, 37]; var results = SampleComponent.TestStuff.computeAverage(data); var formattedResults = "Min=" + results.minValue + ", Avg=" + results.value + ", Max=" + results.maxValue; - ``` You must give the return value a different name if you already have a parameter named "value". Or you might simply want to use a more meaningful name (such as "average" in this example). Apply the attribute to your method and specify a new name. @@ -74,7 +72,6 @@ public static int ComputeAverage([ReadOnlyArray()] int[] input, { … } - ``` ```vb @@ -85,7 +82,6 @@ Public Shared Function ComputeAverage( _ As Integer … End Function - ``` ]]> diff --git a/xml/System.Runtime.Serialization/DataContractSerializer.xml b/xml/System.Runtime.Serialization/DataContractSerializer.xml index c69a10b2ca7..da24458cd0c 100644 --- a/xml/System.Runtime.Serialization/DataContractSerializer.xml +++ b/xml/System.Runtime.Serialization/DataContractSerializer.xml @@ -1186,14 +1186,19 @@ ## Remarks This property can be set in configuration or imperatively in code. To set it in configuration, add a custom behavior to the behaviors section and add the following setting. -``` - +```xml + + + + + ``` - To set this property imperatively in code find the operation description of the service, then get the operation behavior, finally set the property as shown in the following code. + To set this property imperatively in code, find the operation description of the service, then get the operation behavior, and finally set the property as shown in the following code. -``` -OperationDescription operation = host.Description.Endpoints[0].Contract.Operations.Find("MyOperationName");operation.Behaviors.Find().MaxItemsInObjectGraph = 3; +```csharp +OperationDescription operation = host.Description.Endpoints[0].Contract.Operations.Find("MyOperationName"); +operation.Behaviors.Find().MaxItemsInObjectGraph = 3; ``` The property specifies the maximum number of objects that the serializer serializes or deserializes in a single method call. (The method always reads one root object, but this object may have other objects in its data members. Those objects may have other objects, and so on.) The default is . Note that when serializing or deserializing arrays, every array entry counts as a separate object. Also, note that some objects may have a large memory representation and so this quota alone may not be sufficient to prevent Denial of Service attacks. For more information, see [Security Considerations for Data](/dotnet/framework/wcf/feature-details/security-considerations-for-data). If you need to increase this quota beyond its default value, it is important to do so both on the sending (serializing) and receiving (deserializing) sides. It applies both when reading and writing data. diff --git a/xml/System.Security.Claims/Claim.xml b/xml/System.Security.Claims/Claim.xml index bf1e4051251..2044f7f3a56 100644 --- a/xml/System.Security.Claims/Claim.xml +++ b/xml/System.Security.Claims/Claim.xml @@ -91,7 +91,6 @@ if (null != principal) } } - ``` ]]> diff --git a/xml/System.Security.Claims/ClaimsAuthorizationManager.xml b/xml/System.Security.Claims/ClaimsAuthorizationManager.xml index 086e02908ef..a2bce789066 100644 --- a/xml/System.Security.Claims/ClaimsAuthorizationManager.xml +++ b/xml/System.Security.Claims/ClaimsAuthorizationManager.xml @@ -55,7 +55,7 @@ The policy used by the claims authorization manager is specified by custom `` elements under the [<claimsAuthorizationManager>](/dotnet/framework/configure-apps/file-schema/windows-identity-foundation/claimsauthorizationmanager) element. In the first policy, the principal must possess one of the specified claims in order to perform the specified action on the specified resource. In the second policy, the principal must possess both claims to be able to perform the specified action on the specified resource. In all others, the principal is automatically granted access regardless of the claims it possesses. -``` +```xml @@ -222,7 +222,7 @@ The policy used by the claims authorization manager is specified by custom `` elements under the [<claimsAuthorizationManager>](/dotnet/framework/configure-apps/file-schema/windows-identity-foundation/claimsauthorizationmanager) element. This policy is read and compiled by the method. In the first policy, the principal must possess one of the specified claims in order to perform the specified action on the specified resource. In the second policy, the principal must possess both claims to be able to perform the specified action on the specified resource. In all others, the principal is automatically granted access regardless of the claims it possesses. -``` +```xml @@ -304,7 +304,7 @@ The policy used by the claims authorization manager is specified by custom `` elements under the [<claimsAuthorizationManager>](/dotnet/framework/configure-apps/file-schema/windows-identity-foundation/claimsauthorizationmanager) element. This policy is read and compiled by the method. In the first policy, the principal must possess one of the specified claims in order to perform the specified action on the specified resource. In the second policy, the principal must possess both claims to be able to perform the specified action on the specified resource. In all others, the principal is automatically granted access regardless of the claims it possesses. -``` +```xml diff --git a/xml/System.Security.Cryptography.X509Certificates/X500DistinguishedNameBuilder.xml b/xml/System.Security.Cryptography.X509Certificates/X500DistinguishedNameBuilder.xml index 7c566c4ad04..fd0f6b18d46 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X500DistinguishedNameBuilder.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X500DistinguishedNameBuilder.xml @@ -31,7 +31,7 @@ When constructing the `SEQUENCE OF` `Relative Distinguished Names`, this builder constructs the `SEQUENCE OF` in the opposite order which they were added to the builder. For example: -```cs + ```csharp builder.AddCommonName("Contoso"); builder.AddCountryOrRegion("US"); ``` diff --git a/xml/System.Security.Cryptography.Xml/CipherReference.xml b/xml/System.Security.Cryptography.Xml/CipherReference.xml index 6d1def7537d..1f5273320a5 100644 --- a/xml/System.Security.Cryptography.Xml/CipherReference.xml +++ b/xml/System.Security.Cryptography.Xml/CipherReference.xml @@ -51,14 +51,12 @@ If you are sure the documents you are decrypting can be trusted, you can change this behavior for fully trusted applications by using the following code: -``` +```csharp Evidence ev = new Evidence(); ev.AddHost (new Zone(SecurityZone.MyComputer)); EncryptedXml exml = new EncryptedXml(doc, ev); ``` - - ## Examples The following code example creates a new instance of . diff --git a/xml/System.Security.Cryptography/RSA.xml b/xml/System.Security.Cryptography/RSA.xml index cf730ef32b1..9451164be13 100644 --- a/xml/System.Security.Cryptography/RSA.xml +++ b/xml/System.Security.Cryptography/RSA.xml @@ -2707,7 +2707,7 @@ An error occurred creating the signature. When you pass `true` to the method, the resulting XML string takes the following form: -``` +```xml @@ -2722,7 +2722,7 @@ An error occurred creating the signature. When you pass `false` to the method, the resulting XML string takes the following form: -``` +```xml diff --git a/xml/System.Security.Principal/WindowsIdentity.xml b/xml/System.Security.Principal/WindowsIdentity.xml index 4fe8747ff44..a9dd49ec001 100644 --- a/xml/System.Security.Principal/WindowsIdentity.xml +++ b/xml/System.Security.Principal/WindowsIdentity.xml @@ -1988,7 +1988,6 @@ public class ImpersonationDemo Console.WriteLine("After impersonation: " + WindowsIdentity.GetCurrent().Name); } } - ``` ]]> @@ -2133,7 +2132,6 @@ public class ImpersonationDemo Console.WriteLine("After impersonation: " + WindowsIdentity.GetCurrent().Name); } } - ``` ]]> diff --git a/xml/System.Threading.Tasks/Task.xml b/xml/System.Threading.Tasks/Task.xml index 025d77e125d..b8812b8ed90 100644 --- a/xml/System.Threading.Tasks/Task.xml +++ b/xml/System.Threading.Tasks/Task.xml @@ -1099,13 +1099,10 @@ When an asynchronous method awaits a directly ## Remarks The returned will not be scheduled for execution until the current task has completed. If the continuation criteria specified through the `continuationOptions` parameter are not met, the continuation task will be canceled instead of scheduled. - - ## Examples The following example demonstrates using to specify that a continuation task should run synchronously when the antecedent task completes. (If the specified task has already completed by the time is called, the synchronous continuation will run on the thread calling .) ```csharp - public class TaskCounter { private volatile int _count; @@ -1119,11 +1116,9 @@ public class TaskCounter public int NumberOfActiveTasks { get { return _count; } } } - ``` ```vb - Public Class TaskCounter Private _count as Integer @@ -1142,7 +1137,6 @@ Public Class TaskCounter End Get End Property End Class - ``` ]]> @@ -1502,7 +1496,6 @@ End Class The following is an example of using ContinueWith to run work both in the background and on the user interface threads. ```csharp - private void Button1_Click(object sender, EventArgs e) { var backgroundScheduler = TaskScheduler.Default; @@ -1514,11 +1507,9 @@ private void Button1_Click(object sender, EventArgs e) backgroundScheduler). ContinueWith(delegate { UpdateUIAgain(); }, uiScheduler); } - ``` ```vb - Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim backgroundScheduler = TaskScheduler.Default @@ -1534,7 +1525,6 @@ Private Sub Button1_Click(ByVal sender As System.Object, UpdateUIAgain() End Sub, uiScheduler) End Sub - ``` ]]> @@ -2824,7 +2814,7 @@ End Sub Note that this example includes a potential race condition: it depends on the task asynchronously executing the delay when the token is cancelled. Although the 1.5 second delay from the call to the method makes that assumption likely, it is nevertheless possible that the call to the method could return before the token is cancelled. In that case, the example produces the following output: -``` +```txt Task t Status: RanToCompletion, Result: 42 ``` diff --git a/xml/System.Threading/SemaphoreSlim.xml b/xml/System.Threading/SemaphoreSlim.xml index 9e103d51335..0ea58881bda 100644 --- a/xml/System.Threading/SemaphoreSlim.xml +++ b/xml/System.Threading/SemaphoreSlim.xml @@ -75,14 +75,12 @@ The basic structure for code that uses a semaphore to protect resources is: ```vb - ' Enter semaphore by calling one of the Wait or WaitAsync methods. SemaphoreSlim.Wait() ' ' Execute code protected by the semaphore. ' SemaphoreSlim.Release() - ``` When all threads have released the semaphore, the count is at the maximum value specified when the semaphore was created. The semaphore's count is available from the property. @@ -90,8 +88,6 @@ SemaphoreSlim.Release() > [!IMPORTANT] > The class doesn't enforce thread or task identity on calls to the , , and methods. In addition, if the constructor is used to instantiate the object, the property can increase beyond the value set by the constructor. It is the programmer's responsibility to ensure that calls to or methods are appropriately paired with calls to methods. - - ## Examples The following example creates a semaphore with a maximum count of three threads and an initial count of zero threads. The example starts five tasks, all of which block waiting for the semaphore. The main thread calls the overload to increase the semaphore count to its maximum, which allows three tasks to enter the semaphore. Each time the semaphore is released, the previous semaphore count is displayed. Console messages track semaphore use. The simulated work interval is increased slightly for each thread to make the output easier to read.