-
Notifications
You must be signed in to change notification settings - Fork 19
Adjust overloads and parameter order to resolve potential ambiguous method call errors #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust overloads and parameter order to resolve potential ambiguous method call errors #59
Conversation
…er pre-existing parameters.
public static LoggerConfiguration TCPSink( | ||
this LoggerSinkConfiguration loggerConfiguration, | ||
string uri, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) | ||
{ | ||
return TCPSink(loggerConfiguration, uri, null, null, null, restrictedToMinimumLevel); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overload was added in #51 and included in 3.0.0-alpha.1. Code like TCPSink("tcp://localhost:1234")
would get an ambiguous call error because both this overload and the one above could match.
I think this one can be safely removed since it is only in an alpha release and the same functionality can be achieved using the overload above with args like TCPSink("tcp://localhost:1234")
or TCPSink("tcp://localhost:1234", restrictedToMinimumLevel: logLevel)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I added this because of #51 (comment).
But as we are going for a major, removing this is fine I guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but I was thinking that rather than add that overload, we could address the concern in that comment by putting the new optional parameters writeTimeoutMs
and disposeTimeoutMs
at the end of the existing methods, e.g.
public static LoggerConfiguration TCPSink(
this LoggerSinkConfiguration loggerConfiguration,
string uri,
ITextFormatter? textFormatter = null,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
int? writeTimeoutMs = null,
int? disposeTimeoutMs = null)
That way, existing code that was calling that existing method like cfg.TCPSink("tcp://localhost:1234", new LogstashJsonFormatter(), LogEventLevel.Debug)
would still work and be compatible with the new signature (it would use the default args writeTimeoutMs = null
and disposeTimeoutMs = null
).
Does that make sense and seem OK to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, works for me.
public static LoggerConfiguration TCPSink( | ||
this LoggerSinkConfiguration loggerConfiguration, | ||
IPAddress ipAddress, | ||
int port, | ||
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overload
public static LoggerConfiguration TCPSink(
this LoggerSinkConfiguration loggerConfiguration,
IPAddress ipAddress,
int port,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
was added in #51 included in 3.0.0-alpha.1 but I think can be safely removed. It can cause ambiguous call errors with code like TCPSink(IPAddress.Parse("127.0.0.1"), 1234)
because the overload above could also match.
I think this is OK to remove because the overload above can cover the same functionality/parameters with calls like this:
TCPSink(IPAddress.Parse("127.0.0.1"), 1234, restrictedToMinimumLevel: logLevel)
fixes #58
int? writeTimeoutMs = null, int? disposeTimeoutMs = null
added in Fix infinite hang #51 to the end of the parameter lists of pre-existing methods to maintain signature compatibility with 2.x version of this library.TCPSink(string uri)
to verify it is no longer an ambiguous method call.