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
| [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.
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
Dataor something else is a better name. To me, the wordsResultandResponseare bit too close semantically and are pretty much interchangeable. - Is it possible to add a
T : classconstraint? - It might be helpful to add
HasDataand/orTryGetData(...)APIs. IfTis constrained toclass, declareDataasT?and then add[MemberNotNullWhen(true, Data)]toHasDataand[NotNullWhen(true)]toTryGetData. StopHandlingfeels 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 aRemoteResponsemight have aResultandStopHandling == 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.
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.
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
RazorServicesandServices.props.