-
Notifications
You must be signed in to change notification settings - Fork 196
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
Cohost document highlighting #10656
Cohost document highlighting #10656
Conversation
It's a complete coincidence I'm adding this now, and definitely not because I made a mistake in one of the aforementioned places
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/LinePositionSpanExtensions.cs
Outdated
Show resolved
Hide resolved
…ns/LinePositionSpanExtensions.cs
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.
Looks good!
[DataContract] | ||
internal record struct RemoteResponse<T>( | ||
[property: DataMember(Order = 0)] bool StopHandling, | ||
[property: DataMember(Order = 1)] T Result) |
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 love elevating this concept so that any service can use it. I have a few ideas and thoughts that you can take or leave:
- Consider whether
Data
or something else is a better name. To me, the wordsResult
andResponse
are bit too close semantically and are pretty much interchangeable. - Is it possible to add a
T : class
constraint? - It might be helpful to add
HasData
and/orTryGetData(...)
APIs. IfT
is constrained toclass
, declareData
asT?
and then add[MemberNotNullWhen(true, Data)]
toHasData
and[NotNullWhen(true)]
toTryGetData
. StopHandling
feels a little awkward to "handle" on the client side. I wonder if there's a better name or combination of signals. In general, it feels strange that the remote service would have so much knowledge about what the client does with the response. It also feels a bit odd to me that aRemoteResponse
might have aResult
andStopHandling == false
. I don't have any great suggestions, so please don't make any changes related to this unless you have better ideas. However, I suggest that we keep thinking on this logic.
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 type is the epitomy of "naming is hard". Trying to work out names for the parameters, and the helper properties, that didn't clash and meant something etc. I do not disagree with any of your feedback.
I'd like to re-use part of this PR in the inlay hint work I'm currently doing though, so if you don't mind I think I'll merge this as is, but will do another pass on this class specifically in a separate PR. I think making it not a record might be the key, so we can separate out consructor params, properties etc. and allow some more nuance in these.
I will say for your item number 2, at the moment no, the first use of this was with Roslyn's TextChange
which is a struct. It certainly would have made the nullability bits easier though :)
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 have no problem with merging this as is. I just wanted to write my thoughts down. We can definitely get back to them later as we go.
Part of #9519
Brings document highlight to cohosting, including tests. Also added some basic tests for
RazorServices
andServices.props
.