-
Notifications
You must be signed in to change notification settings - Fork 5k
Stream related constants for default constructor parameters should be public #29096
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
Comments
.Net already has a way to do this: optional parameters with defaults. Is providing these values as their own members really better than optional parameters? |
Normally no. In this case, however, we've got existing constructors that make adding default parameters untenable. |
Optional parameters with defaults won't work in this case, as @JeremyKuhne mentioned. Unless the decision from (https://github.com/dotnet/corefx/issues/470#issuecomment-147809240) is going to be reversed (or ignored), optional parameters aren't recommended on public API surfaces. Also, @svick, this is the same issue you referenced in #17157:
|
If these values are made public it should be a static property. I personally think this should not be public and any issues with constructor overloads should be dealt with in a different way. Various ideas for that have been proposed. A solution such as |
@GSPP if we add it as a a static property to the I mention this because many of our own stream-derived types define their own internal or private |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
This issue will now be closed since it had been marked |
The
Stream
classes have various constants that define default values (for things like the default buffer size) which are either internal or private. These should become public so they can be referenced by calling code (to provide the proper defaults when having to use some of the various constructor overloads).In addition, there are a few defaults used (for example, the default encoding for
StreamReader
) which are not defined by a constant but instead repeated in the various constructor overloads as a direct parameter. These should be pulled out as new public constants as well.Originally posted by @JeremyKuhne in https://github.com/dotnet/corefx/issues/8173#issuecomment-477301802
The text was updated successfully, but these errors were encountered: