Use consistent pattern for namespace of extension methods#1576
Merged
cijothomas merged 11 commits intoopen-telemetry:masterfrom Nov 18, 2020
Merged
Conversation
…they are extending
Codecov Report
@@ Coverage Diff @@
## master #1576 +/- ##
=======================================
Coverage 80.73% 80.73%
=======================================
Files 242 242
Lines 6544 6544
=======================================
Hits 5283 5283
Misses 1261 1261
|
cijothomas
reviewed
Nov 18, 2020
cijothomas
approved these changes
Nov 18, 2020
Member
cijothomas
left a comment
There was a problem hiding this comment.
This looks good to me. We want to add this to changelog before merge.
cijothomas
reviewed
Nov 18, 2020
src/OpenTelemetry.Exporter.Console/.publicApi/net452/PublicAPI.Unshipped.txt
Show resolved
Hide resolved
Member
|
@reyang @CodeBlanch please share your thoughts as well. |
eddynaka
approved these changes
Nov 18, 2020
…anwest/opentelemetry-dotnet into alanwest/consistent-extension-methods
cijothomas
approved these changes
Nov 18, 2020
Member
|
I definitely agree with the approach that (in most cases) extensions should live in the namespace of whatever is being extended. Thanks @alanwest! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an alternative to #1541.
I'm beginning to lean more towards leaving things alone for the most part. That is, I think the general rule of thumb that has been followed is to place extension methods in the same namespace as the type that they are extending. This is what Microsoft has followed with many of their libraries (e.g., Microsoft.Extensions.Configuration, Microsoft.Extensions.Logging, etc.).
However, there are a few places that do not follow this rule. I believe some of them are intentional exceptions to the rule, but some of them may have been unintentional.
I this PR, I've tracked down all of the public extension methods that are not contained in the same namespace as the type they are extending and changed them to be in the same namespace. There were two notable exceptions that I think are sensible exceptions to this general rule - I added a comment explaining why - please confirm the accuracy of my comments.
Questions: