Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mismatches for parameter names between reference and implementation assembly #19763

Closed
@Anipik

Description

@Anipik

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

cc @ericstj
PR dotnet/runtime#39741


Issue metadata

  • Issue type: breaking-change

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 5Work items for the .NET 5 releasebreaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions