Closed
Description
There are mismatches between argument names of some of the the apis between the ref assembly and the implementation assembly. This could cause problems while using named arguments and reflection.
Version introduced
These mismatches were present when these new apis were introduced.
Old behavior
namespace System.CodeDom.Compiler
{
public abstract class CodeGenerator : ICodeGenerator
{
protected void GenerateStatements(CodeStatementCollection stms) {}
}
}
namespace System.Diagnostics
{
public class StackTrace
{
public StackFrame(bool fNeedFileInfo) { }
public StackFrame(int skipFrames, bool fNeedFileInfo) { }
}
}
namespace System.Net
{
public class NetworkCredential : ICredentials, ICredentialsByHost
{
public NetworkCredential GetCredential(string host, int port, string authType){}
}
public class IPAddress
{
public static System.Net.IPAddress Parse(System.ReadOnlySpan<char> ipString) { throw null; }
public static bool TryParse(ReadOnlySpan<char> ipString, out IPAddress address);
}
}
namespace System
{
public static class StringNormalizationExtensions
{
public static bool IsNormalized(this string value) { }
public static bool IsNormalized(this string value, System.Text.NormalizationForm normalizationForm) { }
public static string Normalize(this string value) { }
public static string Normalize(this string value, System.Text.NormalizationForm normalizationForm) { }
}
}
namespace System.IO.IsolatedStorage
{
public class IsolatedStorageFileStream : FileStream
{
public override IAsyncResult BeginRead(byte[] buffer, int offset, int numBytes, AsyncCallback userCallback, object stateObject);
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int numBytes, AsyncCallback userCallback, object stateObject);
}
}
namespace System.ComponentModel
{
public sealed class ParenthesizePropertyNameAttribute : Attribute
{
public override bool Equals(object o);
}
public sealed class RefreshPropertiesAttribute : Attribute
{
public override bool Equals(object value);
}
}
namespace System.Drawing
{
public sealed class Icon : MarshalByRefObject, ICloneable, IDisposable, ISerializable
{
void System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo info, StreamingContext context);
}
public abstract class Image : MarshalByRefObject, ICloneable, IDisposable, ISerializable
{
void System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo info, StreamingContext context);
}
}
New behavior
namespace System.CodeDom.Compiler
{
public abstract class CodeGenerator : ICodeGenerator
{
protected void GenerateStatements(CodeStatementCollection stmts) {}
}
}
namespace System.Diagnostics
{
public class StackTrace
{
public StackFrame(bool needFileInfo) { }
public StackFrame(int skipFrames, bool needFileInfo) { }
}
}
namespace System.Net
{
public class NetworkCredential : ICredentials, ICredentialsByHost
{
public NetworkCredential GetCredential(string host, int port, string authenticationType){ }
}
public class IPAddress
{
public static System.Net.IPAddress Parse(System.ReadOnlySpan<char> ipSpan) { }
public static bool TryParse(ReadOnlySpan<char> ipSpan, out IPAddress address) { }
}
}
namespace System
{
public static class StringNormalizationExtensions
{
public static bool IsNormalized(this string strInput) { }
public static bool IsNormalized(this string strInput, System.Text.NormalizationForm normalizationForm) { }
public static string Normalize(this string strInput) { }
public static string Normalize(this string strInput, System.Text.NormalizationForm normalizationForm) { }
}
}
namespace System.IO.IsolatedStorage
{
public class IsolatedStorageFileStream : FileStream
{
public override IAsyncResult BeginRead(byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject);
public override IAsyncResult BeginWrite(byte[] array, int offset, int numBytes, AsyncCallback userCallback, object stateObject);
}
}
namespace System.ComponentModel
{
public sealed class ParenthesizePropertyNameAttribute : Attribute
{
public override bool Equals(object obj);
}
public sealed class RefreshPropertiesAttribute : Attribute
{
public override bool Equals(object obj);
}
}
namespace System.Drawing
{
public sealed class Icon : MarshalByRefObject, ICloneable, IDisposable, ISerializable
{
void System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context);
}
public abstract class Image : MarshalByRefObject, ICloneable, IDisposable, ISerializable
{
void System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context);
}
}
Reason for change
- Consistency.
- Avoid failures while using named arguments and reflection.
Recommended action
There could be a compile error which could be easily resolved by changing the argument name.
Category
- Core .NET libraries
Affected APIs
- https://docs.microsoft.com/en-us/dotnet/api/system.codedom.compiler.codegenerator.generatestatements?view=dotnet-plat-ext-3.1
- https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.stacktrace.-ctor?view=netcore-3.1#System_Diagnostics_StackTrace__ctor_System_Boolean_
- https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.stacktrace.-ctor?view=netcore-3.1#System_Diagnostics_StackTrace__ctor_System_Int32_System_Boolean_
- https://docs.microsoft.com/en-us/dotnet/api/system.net.networkcredential.getcredential?view=netcore-3.1#System_Net_NetworkCredential_GetCredential_System_String_System_Int32_System_String_
-https://docs.microsoft.com/en-us/dotnet/api/system.net.ipaddress.parse?view=netcore-3.1 - https://docs.microsoft.com/en-us/dotnet/api/system.net.ipaddress.tryparse?view=netcore-3.1#System_Net_IPAddress_TryParse_System_ReadOnlySpan_System_Char__System_Net_IPAddress__
- https://docs.microsoft.com/en-us/dotnet/api/system.stringnormalizationextensions.isnormalized?view=netcore-3.1#System_StringNormalizationExtensions_IsNormalized_System_String_System_Text_NormalizationForm_
- https://docs.microsoft.com/en-us/dotnet/api/system.stringnormalizationextensions.isnormalized?view=netcore-3.1#System_StringNormalizationExtensions_IsNormalized_System_String_
- https://docs.microsoft.com/en-us/dotnet/api/system.stringnormalizationextensions.normalize?view=netcore-3.1#System_StringNormalizationExtensions_Normalize_System_String_System_Text_NormalizationForm_
- https://docs.microsoft.com/en-us/dotnet/api/system.stringnormalizationextensions.normalize?view=netcore-3.1#System_StringNormalizationExtensions_Normalize_System_String_
- https://docs.microsoft.com/en-us/dotnet/api/system.io.isolatedstorage.isolatedstoragefilestream.beginread?view=netcore-3.1
- https://docs.microsoft.com/en-us/dotnet/api/system.io.isolatedstorage.isolatedstoragefilestream.beginwrite?view=netcore-3.1
- https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.parenthesizepropertynameattribute.equals?view=netcore-3.1
- https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.refreshpropertiesattribute.equals?view=netcore-3.1
cc @ericstj
PR dotnet/runtime#39741
Issue metadata
- Issue type: breaking-change