[Proposal]: UTF-8 Literal Pattern Matching Support
UTF-8 Literal Pattern Matching Support
- [x] Proposed
- [ ] Prototype: Not Started
- [ ] Implementation: Not Started
- [ ] Specification: Not Started
The LDM looked at the concept and approved it in theory, but it needs an approved specification. This is in the Any Time milestone, so we'd accept a specification from a community member.
Original discussion: https://github.com/dotnet/csharplang/discussions/6036
Design Meetings
- https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-05-11.md#pattern-matching-with-utf-8-string-literals
@333fred I would like to try writing a specification for this proposal (will be able to start next week).
Go for it, though I will be out until late August.
It would be very useful if C# also provided the ability to specify a UTF-8 string (e.g., "MyUtf8String"u8) as a constant, which would then allow such constants to be used in the respective case statements of a switch statement. That would then have the potential to allow developers to more easily build much more efficient JsonConverter<T> implementations because at present, each JSON property is found/identified through a chain of if/else-if statements using Utf8JsonReader.ValueTextEquals calls.
If the switch statement performance improvements for switching string options implemented in .NET 8 were to be made available for UTF-8 strings and then employed in JsonConverter<T> implementations, we could see a significant performance boost in JSON deserialization.