### GC Control Methods (.NET) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md This code snippet details new methods added to the `GC` class for more granular control over garbage collection. `Collect` allows specifying the generation, collection mode, and whether to block or compact. `EndNoGCRegion` terminates a region where garbage collection was disallowed. `TryStartNoGCRegion` provides methods to attempt starting a no-GC region, with overloads allowing specification of total size, LOH size, and whether to disallow full blocking GC. ```csharp public static void Collect(int generation, GCCollectionMode mode, bool blocking, bool compacting); public static void EndNoGCRegion(); public static bool TryStartNoGCRegion(long totalSize); public static bool TryStartNoGCRegion(long totalSize, bool disallowFullBlockingGC); public static bool TryStartNoGCRegion(long totalSize, long lohSize); public static bool TryStartNoGCRegion(long totalSize, long lohSize, bool disallowFullBlockingGC); ``` -------------------------------- ### Vector3 Arithmetic and Transformation Operations in C# Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.html Provides C# code examples for common Vector3 operations like multiplication, negation, normalization, reflection, square root, subtraction, addition, and transformation using matrices and quaternions. These methods are often optimized with AggressiveInlining. ```csharp // Multiplication operations [MethodImpl(AggressiveInlining)] public static Vector3 Multiply(Vector3 left, Vector3 right); [MethodImpl(AggressiveInlining)] public static Vector3 Multiply(Vector3 left, float right); [MethodImpl(AggressiveInlining)] public static Vector3 Multiply(float left, Vector3 right); // Negation and Normalization [MethodImpl(AggressiveInlining)] public static Vector3 Negate(Vector3 value); [MethodImpl(AggressiveInlining)] public static Vector3 Normalize(Vector3 value); // Operator overloads for arithmetic [MethodImpl(AggressiveInlining)] public static Vector3 operator +(Vector3 left, Vector3 right); [MethodImpl(AggressiveInlining)] public static Vector3 operator -(Vector3 left, Vector3 right); [MethodImpl(AggressiveInlining)] public static Vector3 operator -(Vector3 value); // Unary minus [MethodImpl(AggressiveInlining)] public static Vector3 operator *(Vector3 left, Vector3 right); [MethodImpl(AggressiveInlining)] public static Vector3 operator *(Vector3 left, float right); [MethodImpl(AggressiveInlining)] public static Vector3 operator *(float left, Vector3 right); [MethodImpl(AggressiveInlining)] public static Vector3 operator /(Vector3 left, Vector3 right); [MethodImpl(AggressiveInlining)] public static Vector3 operator /(Vector3 value1, float value2); // Other mathematical operations [MethodImpl(AggressiveInlining)] public static Vector3 Reflect(Vector3 vector, Vector3 normal); [MethodImpl(AggressiveInlining)] public static Vector3 SquareRoot(Vector3 value); [MethodImpl(AggressiveInlining)] public static Vector3 Subtract(Vector3 left, Vector3 right); [MethodImpl(AggressiveInlining)] public static Vector3 Add(Vector3 left, Vector3 right); // Transformation methods [MethodImpl(AggressiveInlining)] public static Vector3 Transform(Vector3 position, Matrix4x4 matrix); [MethodImpl(AggressiveInlining)] public static Vector3 Transform(Vector3 value, Quaternion rotation); [MethodImpl(AggressiveInlining)] public static Vector3 TransformNormal(Vector3 normal, Matrix4x4 matrix); ``` -------------------------------- ### RegistryKey Creation and Opening in C# Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Shows methods for creating and opening registry keys using the 'RegistryKey' class in C#. Includes variations for specifying writability and registry options, and for opening with specific rights. ```csharp public sealed class RegistryKey : MarshalByRefObject, IDisposable { public RegistryKey CreateSubKey(string subkey, bool writable); public RegistryKey CreateSubKey(string subkey, bool writable, RegistryOptions options); public RegistryKey OpenSubKey(string name, RegistryRights rights); } ``` -------------------------------- ### System.Uri IdnHost Property Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.html Gets the Internationalized Domain Name (IDN) host part of the specified URI. ```APIDOC ## Uri IdnHost Property ### Description Gets the Internationalized Domain Name (IDN) host part of the specified URI. ### Method `string IdnHost { get; }` ### Endpoint N/A (Instance Property) ### Parameters N/A ### Request Example N/A ### Response - `string`: The IDN host part of the URI. ### Response Example N/A ``` -------------------------------- ### WaitHandleExtensions SafeHandle Access Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Provides extension methods to get and set the SafeWaitHandle associated with a WaitHandle, facilitating interoperation with native code. ```csharp public static class WaitHandleExtensions { public static SafeWaitHandle GetSafeWaitHandle(this WaitHandle waitHandle); public static void SetSafeWaitHandle(this WaitHandle waitHandle, SafeWaitHandle value); } ``` -------------------------------- ### Build .NET Framework Project using MSBuild Source: https://github.com/microsoft/dotnet/blob/main/releases/reference-assemblies/README.md These console commands show the process of building a .NET Framework project after configuring it to use the targeting pack. It includes restoring NuGet packages and then building the project using MSBuild. ```console msbuild /t:restore msbuild ``` -------------------------------- ### System.Diagnostics.Debug.Assert Exceptions Source: https://github.com/microsoft/dotnet/blob/main/Documentation/compatibility/some-_net-apis-cause-first-chance-(handled)-entrypointnotfoundexceptions.md Details about first-chance EntryPointNotFoundExceptions thrown by certain System.Diagnostics.Debug.Assert methods in .NET Framework 4.5. ```APIDOC ## `M:System.Diagnostics.Debug.Assert(System.Boolean)` ### Description This method, along with others in the `System.Diagnostics.Debug.Assert` overload set, may throw first chance `EntryPointNotFoundException`s in .NET Framework 4.5. These exceptions were handled internally but could disrupt test automation. This behavior was reverted in .NET Framework 4.5.1. ### Affected APIs * `M:System.Diagnostics.Debug.Assert(System.Boolean)` * `M:System.Diagnostics.Debug.Assert(System.Boolean,System.String)` * `M:System.Diagnostics.Debug.Assert(System.Boolean,System.String,System.String)` * `M:System.Diagnostics.Debug.Assert(System.Boolean,System.String,System.String,System.Object[])` ### Version Introduced 4.5 ### Version Reverted 4.5.1 ### Recommended Action Upgrade to .NET Framework 4.5.1 or update test automation to handle first-chance `EntryPointNotFoundException`s. ``` -------------------------------- ### Encoding GetString with Unsafe Pointer Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Provides an unsafe method to get a string from a byte array using pointers, allowing for direct memory access. ```csharp public abstract class Encoding : ICloneable { protected Encoding(int codePage, EncoderFallback encoderFallback, DecoderFallback decoderFallback); public unsafe string GetString(byte* bytes, int byteCount); public static void RegisterProvider(EncodingProvider provider); } ``` -------------------------------- ### System.Xml.Serialization.XmlSerializer Constructor Exception Source: https://github.com/microsoft/dotnet/blob/main/Documentation/compatibility/some-_net-apis-cause-first-chance-(handled)-entrypointnotfoundexceptions.md Details about first-chance EntryPointNotFoundExceptions thrown by the System.Xml.Serialization.XmlSerializer constructor in .NET Framework 4.5. ```APIDOC ## `M:System.Xml.Serialization.XmlSerializer.#ctor(System.Type)` ### Description The constructor `System.Xml.Serialization.XmlSerializer.#ctor(System.Type)` may throw first chance `EntryPointNotFoundException`s in .NET Framework 4.5. These exceptions were handled internally but could disrupt test automation. This behavior was reverted in .NET Framework 4.5.1. ### Affected APIs * `M:System.Xml.Serialization.XmlSerializer.#ctor(System.Type)` ### Version Introduced 4.5 ### Version Reverted 4.5.1 ### Recommended Action Upgrade to .NET Framework 4.5.1 or update test automation to handle first-chance `EntryPointNotFoundException`s. ``` -------------------------------- ### ServiceHealthModel Constructor (C#) Source: https://github.com/microsoft/dotnet/blob/main/releases/net48/dotnet48-api-changes.md Initializes a new instance of the ServiceHealthModel class. Overloads allow for initialization with or without a ServiceHostBase object and an optional service start time. ```csharp public ServiceHealthModel(); public ServiceHealthModel(ServiceHostBase serviceHost); public ServiceHealthModel(ServiceHostBase serviceHost, DateTimeOffset serviceStartTime); ``` -------------------------------- ### RSACng and DSACng Partial Trust Behavior Change Source: https://github.com/microsoft/dotnet/blob/main/Documentation/compatibility/RSACng-and-DSACng-not-usable-in-Partial-Trust-scenarios.md This section details the change in behavior for RSACng and DSACng in partial trust scenarios, starting from .NET Framework 4.6.2, and the fix introduced in .NET Framework 4.7.1. ```APIDOC ## RSACng and DSACng Usability in Partial Trust Scenarios ### Description This documentation covers the changes related to RSACng and DSACng, which were previously unusable in partial trust scenarios due to security permission requirements. The issue stemmed from P/Invokes and CngKey permission demands for `UnmanagedCode`. Starting with .NET Framework 4.6.2, these classes began to fail in partial trust applications. A fix was introduced in .NET Framework 4.7.1 by adding the necessary permission asserts. ### Method N/A (This describes a framework behavior change, not a specific API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response (Behavior Change) - **.NET Framework 4.6.2**: RSACng and DSACng may throw `System.Security.SecurityException` in partial trust. - **.NET Framework 4.7.1**: RSACng and DSACng function correctly in partial trust scenarios. ### Affected APIs * `M:System.Security.Cryptography.DSACng.#ctor(System.Security.Cryptography.CngKey)` * `P:System.Security.Cryptography.DSACng.Key` * `P:System.Security.Cryptography.DSACng.LegalKeySizes` * `M:System.Security.Cryptography.DSACng.CreateSignature(System.Byte[])` * `M:System.Security.Cryptography.DSACng.VerifySignature(System.Byte[],System.Byte[])` * `M:System.Security.Cryptography.RSACng.#ctor(System.Security.Cryptography.CngKey)` * `P:System.Security.Cryptography.RSACng.Key` * `M:System.Security.Cryptography.RSACng.Decrypt(System.Byte[],System.Security.Cryptography.RSAEncryptionPadding)` * `M:System.Security.Cryptography.RSACng.SignHash(System.Byte[],System.Security.Cryptography.HashAlgorithmName,System.Security.Cryptography.RSASignaturePadding)` ### Recommended Action If your partial trust applications were negatively impacted by the change in .NET Framework 4.6.2, upgrade to .NET Framework 4.7.1. ``` -------------------------------- ### NU1701 NuGet Warning Explanation Source: https://github.com/microsoft/dotnet/blob/main/releases/UWP/net-native2.0/README.md Explains the NU1701 warning from NuGet, which indicates a package was restored using a different .NET Framework version than the project's target framework. It advises developers to test compatibility or verify with the library author. ```text NU1701: Package 'PackageNameHere 1.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. ``` -------------------------------- ### RSA Create Methods Source: https://github.com/microsoft/dotnet/blob/main/releases/net472/dotnet472-api-changes.md Static methods for creating RSA instances. ```APIDOC ## RSA Create Methods ### Description Static methods for creating instances of the `RSA` (Rivest–Shamir–Adleman) class. ### Class `RSA` ### Static Methods - `public static RSA Create(int keySizeInBits);`: Creates an `RSA` object with the specified key size in bits. - `public static RSA Create(RSAParameters parameters);`: Creates an `RSA` object using the specified parameters. ``` -------------------------------- ### Get X.509 Certificate Hash String - C# Source: https://github.com/microsoft/dotnet/blob/main/releases/net48/dotnet48-api-changes.md Retrieves the hash string of an X.509 certificate using a specified hash algorithm. This is useful for uniquely identifying certificates. ```csharp namespace System.Security.Cryptography.X509Certificates { public class X509Certificate { public virtual string GetCertHashString(HashAlgorithmName hashAlgorithm) } } ``` -------------------------------- ### SqlColumnEncryptionCertificateStoreProvider Constructor and Methods (C#) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Implements SqlColumnEncryptionKeyStoreProvider for managing column encryption keys using certificate stores. Includes methods for encrypting and decrypting keys. ```csharp public SqlColumnEncryptionCertificateStoreProvider(); public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey); public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey); ``` -------------------------------- ### Get Current Thread Allocated Bytes - C# Source: https://github.com/microsoft/dotnet/blob/main/releases/net48/dotnet48-api-changes.md Returns the total number of bytes allocated on the current thread since its inception. This is useful for performance profiling and memory usage analysis. ```csharp namespace System { public static class GC{ public static long GetAllocatedBytesForCurrentThread() } } ``` -------------------------------- ### Dynamic Expression Interface (.NET) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Extends the IArgumentProvider interface for dynamic expressions, adding functionality to get the delegate type and create/rewrite call sites. Used for dynamic operations within expression trees. ```csharp public interface IDynamicExpression : IArgumentProvider { Type DelegateType { get; } object CreateCallSite(); Expression Rewrite(Expression[] args); } ``` -------------------------------- ### Opt-in to Source File/Line Info with Portable PDBs (app.config) Source: https://github.com/microsoft/dotnet/blob/main/Documentation/compatibility/Stack-traces-obtained-when-using-portable-PDBs-now-include-source-file-and-line-information-if-requested.md This configuration snippet shows how to explicitly enable source file and line information in stack traces when using portable PDBs for applications targeting earlier .NET Framework versions but running on .NET Framework 4.7.2 or later. This setting is configured within the `` section of the `app.config` file. ```xml ``` -------------------------------- ### Current Culture and UI Culture Management (.NET) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Illustrates how to get and set the current culture and current UI culture for the application. This affects culture-sensitive operations like date, time, and number formatting. ```csharp public class CultureInfo : ICloneable, IFormatProvider { public static CultureInfo CurrentCulture { get; set; } public static CultureInfo CurrentUICulture { get; set; } } ``` -------------------------------- ### CompareInfo Hash Code Generation with Options (.NET) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Shows how to generate a hash code for a string based on specific comparison options using the CompareInfo class. This is useful for custom sorting or comparison logic. ```csharp public class CompareInfo : IDeserializationCallback { public virtual int GetHashCode(string source, CompareOptions options); } ``` -------------------------------- ### SqlColumnEncryptionKeyStoreProvider Source: https://github.com/microsoft/dotnet/blob/main/releases/net472/dotnet472-api-changes.md Base class for key store providers, including methods for signing and verifying metadata. ```APIDOC ## SqlColumnEncryptionKeyStoreProvider ### Description Abstract base class for SQL column encryption key store providers. It provides virtual methods for signing and verifying column master key metadata. ### Methods - `SignColumnMasterKeyMetadata`: Signs the column master key metadata. - `VerifyColumnMasterKeyMetadata`: Verifies the signature of the column master key metadata. ### Virtual Methods - `public virtual byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations); - `public virtual bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature);` ``` -------------------------------- ### TextLine and PixelsPerDip Property (C#) Source: https://github.com/microsoft/dotnet/blob/main/releases/net462/dotnet462-api-changes.md Demonstrates the TextLine class, which includes a protected constructor accepting pixelsPerDip and a public property to get or set this value. This property is key for accurate text rendering at different DPI scales. ```csharp namespace System.Windows.Media.TextFormatting { public abstract class TextLine : IDisposable, ITextMetrics { protected TextLine(double pixelsPerDip); public double PixelsPerDip { get; set; } } } ``` -------------------------------- ### Application Context Utilities (.NET) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.html Offers static methods for interacting with the application context in .NET. Includes retrieving the base directory and managing feature switches using SetSwitch and TryGetSwitch. These are essential for application configuration and behavior control. ```C# namespace System { public static class AppContext { public static string BaseDirectory { get; } public static void SetSwitch(string switchName, bool isEnabled); public static bool TryGetSwitch(string switchName, out bool isEnabled); } } ``` -------------------------------- ### Set and Get DPI for Visuals (C#) Source: https://github.com/microsoft/dotnet/blob/main/releases/net462/dotnet462-api-changes.md Shows how to use VisualTreeHelper to set the root DPI for a Visual element and retrieve the current DPI scale. This is fundamental for accurate rendering of visuals based on the display's DPI settings. ```csharp namespace System.Windows.Media { public static class VisualTreeHelper { public static DpiScale GetDpi(Visual visual); public static void SetRootDpi(Visual visual, DpiScale dpiInfo); } } ``` -------------------------------- ### Domain Mode and Functionality Level Manipulation (.NET) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Provides methods for interacting with Active Directory domain functionality levels. It includes a property to get the current domain mode level and a method to raise the domain functionality level. ```csharp public class Domain : ActiveDirectoryPartition { public int DomainModeLevel { get; } public void RaiseDomainFunctionalityLevel(int domainMode); } ``` -------------------------------- ### Vector4 Constructors and Properties in C# Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.html Shows C# constructors for initializing Vector4 instances with different combinations of values and properties representing unit vectors and common values like One and Zero. ```csharp // Constructors public Vector4(Vector2 value, float z, float w); public Vector4(Vector3 value, float w); public Vector4(float value); // Initializes all components to the same value public Vector4(float x, float y, float z, float w); // Properties for common values public static Vector4 One { get; } public static Vector4 UnitW { get; } public static Vector4 UnitX { get; } public static Vector4 UnitY { get; } public static Vector4 UnitZ { get; } public static Vector4 Zero { get; } ``` -------------------------------- ### DSA Create Methods Source: https://github.com/microsoft/dotnet/blob/main/releases/net472/dotnet472-api-changes.md Static methods for creating DSA instances. ```APIDOC ## DSA Create Methods ### Description Static methods for creating instances of the `DSA` (Digital Signature Algorithm) class. ### Class `DSA` ### Static Methods - `public static DSA Create(DSAParameters parameters);`: Creates a `DSA` object using the specified parameters. - `public static DSA Create(int keySizeInBits);`: Creates a `DSA` object with the specified key size in bits. ``` -------------------------------- ### ServiceHealthModel.ProcessInformationModel Constructor, Properties, and Method (C#) Source: https://github.com/microsoft/dotnet/blob/main/releases/net48/dotnet48-api-changes.md Captures information about the service host process. It can be initialized with a ServiceHostBase and provides details like process name, uptime, and GC mode. Includes a method to set the service start date. ```csharp public class ProcessInformationModel { public ProcessInformationModel(); public ProcessInformationModel(ServiceHostBase serviceHost); public int Bitness { get; } public string GCMode { get; } public string ProcessName { get; } public DateTimeOffset ProcessStartDate { get; } public DateTimeOffset ServiceStartDate { get; } public ServiceHealthModel.ProcessThreadsModel Threads { get; } public TimeSpan Uptime { get; } public void SetServiceStartDate(DateTimeOffset serviceStartTime); } ``` -------------------------------- ### System.Windows APIs Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md APIs related to core compatibility preferences and visual diagnostics. ```APIDOC ## CoreCompatibilityPreferences ### Description Provides preferences for core compatibility features. ### Properties - `public static Nullable EnableMultiMonitorDisplayClipping { get; set; }`: Gets or sets a value indicating whether multi-monitor display clipping is enabled. ``` -------------------------------- ### Disable CLR Spin-Wait via Environment Variable Source: https://github.com/microsoft/dotnet/blob/main/Documentation/compatibility/clr_critical_section_spin_wait_removal.md This code snippet shows how to disable the CLR critical section spin-wait behavior by setting an environment variable before starting the process. This is a transparent change that affects scalability. ```bash COMPlus_Crst_DisableSpinWait=1 ``` -------------------------------- ### X509Store Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Represents a collection of X.509 certificates, implementing IDisposable. ```APIDOC ## X509Store ### Description Manages a store of X.509 certificates and implements IDisposable. ### Method N/A (Class Definition) ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response (200) N/A #### Response Example N/A ### Dispose Releases the unmanaged resources used by the X509Store. ### Method GET ### Endpoint N/A (Method) ### Parameters None ### Request Example ```csharp X509Store store = ...; store.Dispose(); ``` ### Response #### Success Response (200) void #### Response Example N/A ``` -------------------------------- ### Manage Duplicate Assemblies in .NET Native Builds Source: https://github.com/microsoft/dotnet/blob/main/releases/UWP/net-native2.0/incremental-compilation.md Duplicate assemblies, particularly those with names starting with 'System.' or named 'SharedLibrary.dll', can cause compilation failures (RHB0007) in .NET Native incremental builds. Rename conflicting application assemblies to resolve this. ```text RHBIND : error RHB0007: Could not load input file 'SharedLibrary.mdildll'. ``` -------------------------------- ### SqlCommand Constructor and ColumnEncryptionSetting (C#) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Extends the SqlCommand class to include a constructor that accepts column encryption settings and a property to retrieve these settings. ```csharp public SqlCommand(string cmdText, SqlConnection connection, SqlTransaction transaction, SqlCommandColumnEncryptionSetting columnEncryptionSetting); public SqlCommandColumnEncryptionSetting ColumnEncryptionSetting { get; } ``` -------------------------------- ### WPF ListBox Binding to ADO Master/Detail Data Source: https://github.com/microsoft/dotnet/blob/main/Documentation/compatibility/wpf-MasterDetail-ADOdata-PrimaryKey.md Example of how a WPF ListBox can be bound to the 'OrderDetails' property of a master item in an ADO collection. This binding displays the details related to a specific order. The DataContext is expected to be an 'Order' object. ```xml ``` -------------------------------- ### Template for .NET Breaking Change Documentation Source: https://context7.com/microsoft/dotnet/llms.txt A standardized Markdown template for documenting breaking changes in .NET Framework releases. It includes sections for scope, version introduced, impact, recommended actions, affected APIs, and category, ensuring consistent compatibility documentation. ```markdown ## [Breaking Change Title] ### Scope Major|Minor|Edge|Transparent ### Version Introduced 4.8.1 ### Source Analyzer Status Available|Planned|Investigating|NotPlanned ### Change Description Describe what changed and how it affects applications. For example: Starting in .NET Framework 4.7.2, the SignedXml and SignedCms classes now use SHA256 as the default hash algorithm instead of SHA1 for improved security. - [x] Quirked // Can be controlled via AppContext or config - [ ] Build-time break // Causes compilation errors ### Recommended Action 1. Update code to explicitly specify SHA1 if needed for compatibility: ```csharp var signedXml = new SignedXml(xmlDoc); signedXml.SignedInfo.SignatureMethod = SignedXml.XmlDsigRSASHA1Url; ``` 2. Or add AppContext switch to revert to SHA1 globally: ```xml ``` ### Affected APIs * `T:System.Security.Cryptography.Xml.SignedXml` * `M:System.Security.Cryptography.Xml.SignedXml.ComputeSignature` ### Category Security [More information](https://docs.microsoft.com/dotnet/framework/migration-guide/mitigation-xml-signing) ``` -------------------------------- ### AutomationProperties Setters and Getters (C#) Source: https://github.com/microsoft/dotnet/blob/main/releases/net48/dotnet48-api-changes.md Demonstrates the static methods in the AutomationProperties class for setting and getting 'PositionInSet' and 'SizeOfSet' for DependencyObjects. These properties are used to define an element's position and total count within a logical set, aiding navigation and understanding of complex UI structures. ```csharp public static void SetPositionInSet(DependencyObject element, int value) public static int GetPositionInSet(DependencyObject element) public static void SetSizeOfSet(DependencyObject element, int value) public static int GetSizeOfSet(DependencyObject element) ``` -------------------------------- ### Create ValueTuple Instances (C#) Source: https://github.com/microsoft/dotnet/blob/main/releases/net47/dotnet47-api-changes.md Static factory methods for creating ValueTuple instances with varying numbers of elements. These methods are part of the ValueTuple struct. ```csharp public static ValueTuple Create(T1 item1); public static ValueTuple Create(T1 item1, T2 item2); public static ValueTuple Create(T1 item1, T2 item2, T3 item3); public static ValueTuple Create(T1 item1, T2 item2, T3 item3, T4 item4); public static ValueTuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5); public static ValueTuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6); public static ValueTuple Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7); public static ValueTuple> Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8); public static ValueTuple Create(); ``` -------------------------------- ### Add Assembly Binding Redirect for System.IO.Compression.ZipFile Source: https://github.com/microsoft/dotnet/blob/main/releases/net471/KnownIssues/623552-BCL Higher assembly versions that 4.0.0.0 for System.IO.Compression.ZipFile cannot be loaded without a binding redirect.md This XML configuration snippet provides the necessary binding redirect to resolve the 'System.IO.FileNotFoundException' for 'System.IO.Compression.ZipFile' when targeting .NET Framework 4.7.1. It ensures that the runtime correctly maps older versions of the assembly to the version present on the machine. ```xml ``` -------------------------------- ### WPF XAML: Shared ContextMenu Binding Example Source: https://github.com/microsoft/dotnet/blob/main/Documentation/KnownIssues/wpf-binding-issue.md This XAML snippet demonstrates how to share a ContextMenu among item containers in an ItemsControl. It uses a relative binding to set the DataContext of the shared menu to the PlacementTarget's DataContext, enabling dynamic content based on the data item. ```xml ... other content ... ... other content .... ``` -------------------------------- ### Enable WPF Markup Compiler SHA256 Hashing for Older Frameworks (XML) Source: https://github.com/microsoft/dotnet/blob/main/Documentation/compatibility/wpf-MarkupCompiler-default-hash-algorithm-is-now-SHA256.md This configuration snippet shows how to explicitly enable SHA256 hashing for the WPF Markup Compiler when targeting a framework version earlier than .NET 4.7.2. This requires the .NET Framework 4.7.2 or a later version to be installed on the target machine. ```xml ``` -------------------------------- ### CngAlgorithm Static Properties Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.md Provides static properties for common CNG algorithms. ```APIDOC ## CngAlgorithm ### Description Specifies the names of the Cryptography Next Generation (CNG) algorithms. ### Properties - **public static CngAlgorithm Rsa** - Represents the RSA algorithm. ``` -------------------------------- ### Enable WPF FocusVisual Improvements Below .NET 4.7.2 (XML) Source: https://github.com/microsoft/dotnet/blob/main/Documentation/compatibility/wpf-focus-visual-for-radiobutton-and-checkbox-displays-correctly-when-there-is-no-content.md This XML configuration enables the improved focus visual behavior for RadioButton and CheckBox controls in WPF applications targeting frameworks below .NET 4.7.2. It requires setting multiple AppContext flags to 'false' and assumes .NET Framework 4.7.2 or later is installed. ```xml ``` -------------------------------- ### Create and Open Registry Keys (.NET) Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.html Defines methods for creating and opening registry keys within the .NET Framework. These methods allow for specifying write permissions and registry options. They return RegistryKey objects representing the accessed or created keys. ```C# namespace Microsoft.Win32 { public sealed class RegistryKey : MarshalByRefObject, IDisposable { public RegistryKey CreateSubKey(string subkey, bool writable); public RegistryKey CreateSubKey(string subkey, bool writable, RegistryOptions options); public RegistryKey OpenSubKey(string name, RegistryRights rights); } } ``` -------------------------------- ### C# - Text Encoding and String Manipulation Source: https://github.com/microsoft/dotnet/blob/main/releases/net46/dotnet46-api-changes.html Provides abstract base classes and concrete implementations for text encoding and string manipulation. Includes methods for getting string representations from byte arrays using unsafe pointers, registering encoding providers, and efficiently building strings with `StringBuilder`. Dependencies include System.IO and System.Runtime.Serialization. ```csharp namespace System.Text { public abstract class Encoding : ICloneable { protected Encoding(int codePage, EncoderFallback encoderFallback, DecoderFallback decoderFallback); public unsafe string GetString(byte* bytes, int byteCount); public static void RegisterProvider(EncodingProvider provider); } public abstract class EncodingProvider { public EncodingProvider(); public abstract Encoding GetEncoding(int codepage); public virtual Encoding GetEncoding(int codepage, EncoderFallback encoderFallback, DecoderFallback decoderFallback); public abstract Encoding GetEncoding(string name); public virtual Encoding GetEncoding(string name, EncoderFallback encoderFallback, DecoderFallback decoderFallback); } public sealed class StringBuilder : ISerializable { public unsafe StringBuilder Append(char* value, int valueCount); public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0); public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0, object arg1); public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0, object arg1, object arg2); } } ``` -------------------------------- ### Enable .NET Native FuncEval via VSRegEdit Command Source: https://github.com/microsoft/dotnet/blob/main/releases/UWP/net-native2.0/funceval.md This command demonstrates how to enable the .NET Native Function Evaluation (FuncEval) preview feature by setting a registry key using the VsRegEdit.exe tool. This allows for inspection of WinRT Properties under the debugger. Note that the Visual Studio installation path may need to be adjusted. ```bash "C:\Program Files (x86)\Microsoft Visual Studio\Enterprise\Common7\IDE\VsRegEdit.exe" set "C:\Program Files (x86)\Microsoft Visual Studio\Enterprise" HKCU Debugger NetNativeFuncEvalEnabled DWORD 1 ```