aspnetcore
aspnetcore copied to clipboard
Add Uri StringSyntaxAttribute syntaxes
Add Uri StringSyntaxAttribute syntaxes
- [x] You've read the Contributor Guide and Code of Conduct.
- [x] You've included unit or integration tests for your change, where applicable.
- [x] You've included inline docs for your change, where applicable.
- [x] There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
Description
Adds uri StringSyntaxAttribute syntaxes to all public APIs where an uri is expected.
Closes Uri Task in #44535
Thanks for your PR, @blouflashdb. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.
Well somehow I can't use it in HubConnectionBuilderHttpExtensions.cs for some reason. Check failure on line 26 in src/SignalR/clients/csharp/Client/src/HubConnectionBuilderHttpExtensions.cs
Azure Pipelines / aspnetcore-ci (Build Build: Linux ARM) src/SignalR/clients/csharp/Client/src/HubConnectionBuilderHttpExtensions.cs#L26 src/SignalR/clients/csharp/Client/src/HubConnectionBuilderHttpExtensions.cs(26,131): error CS0122: (NETCORE_ENGINEERING_TELEMETRY=Build) 'StringSyntaxAttribute' is inaccessible due to its protection level
The SignalR client also targets .NET Framework, which doesn't have that attribute.
To work around this:
- Copy the attribute's source code from StringSyntaxAttribute.cs
- Add an internal polyfill type in the Shared/CodeAnalysis directory - https://github.com/dotnet/aspnetcore/tree/1b53b22a866eb4bc58f2d5552db7f3ac08f1a952/src/Shared/CodeAnalysis. The trimming types already in that directory are a good example of this technique.
- Finally, add a link to the shared source file from the SignalR client project.
It doesn't matter that the attribute is internal and in a different assembly. As long as the type name and namespace match, tooling and other apps can use it.
Thanks, I think I got it.