Skip to content

Conversation

@CodeBlanch
Copy link
Contributor

@ghost
Copy link

ghost commented Apr 12, 2022

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost added area-System.Diagnostics.Activity new-api-needs-documentation community-contribution Indicates that the PR has been added by a community member labels Apr 12, 2022
@ghost
Copy link

ghost commented Apr 12, 2022

Tagging subscribers to this area: @dotnet/area-system-diagnostics-activity
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #67207

/cc @reyang @cijothomas @tarekgh @noahfalk

Author: CodeBlanch
Assignees: -
Labels:

new-api-needs-documentation, area-System.Diagnostics.Activity

Milestone: -

@tarekgh
Copy link
Member

tarekgh commented Apr 12, 2022

Thanks @CodeBlanch for helping all the way with this issue. I'll wait @noahfalk feedback and then will merge it.

@tarekgh
Copy link
Member

tarekgh commented Apr 12, 2022

@CodeBlanch one last thing I forgot to ask, could you please ensure the return values of the methods is working fine with foreach?

@CodeBlanch
Copy link
Contributor Author

@tarekgh Sure, np. Added foreach verification into the tests.

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


public struct Enumerator<T>
{
public readonly System.Diagnostics.Activity.Enumerator<T> GetEnumerator() { throw null; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just here to make the C# compiler happy when doing a foreach loop? It feels like we are abusing the Enumerable/Enumerator pattern a bit but as long as BCL review team was happy with it I am happy too : )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just here to make the C# compiler happy when doing a foreach loop?

Yes

It feels like we are abusing the Enumerable/Enumerator pattern a bit but as long as BCL review team was happy with it I am happy too : )

Actually this was recommended by the BCL design reviewers :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI here are a couple other examples of this being done that came up during the review:

public ChunkEnumerator GetEnumerator() { return this; }

public StringRuneEnumerator GetEnumerator() => this;

Brings up a question, should we add...

[ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Never)]

...like ChunkEnumerator is doing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI here are a couple other examples of this being done that came up during the review:

Actually, StringRuneEnumerator is implementing IEnumerable<>.

Brings up a question, should we add...

Good point. Please go ahead and apply the attribute as we did in StringBuilder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks you need to update the ref file too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Sorry rookie move 😄

@AndyAyersMS
Copy link
Member

Are we expecting any perf impact here?

Possible regression seen on arm64: #68624

@tarekgh
Copy link
Member

tarekgh commented Apr 22, 2022

@AndyAyersMS looking at the perf test code

https://github.com/dotnet/performance/blob/d7dac8a7ca12a28d099192f8a901cf8e30361384/src/benchmarks/micro/libraries/System.Diagnostics/Perf_Activity.cs#L188

I cannot relate the changes in this PR to the operations we are doing in the test. All changes in this PR mostly for some properties enumeration which is not used in the test at all.

@ghost ghost locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: System.Diagnostics.Activity: Enumeration API [Iteration 2]

4 participants