aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Add Uri StringSyntaxAttribute syntaxes

Open blouflashdb opened this issue 3 years ago • 2 comments

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

blouflashdb avatar Oct 15 '22 14:10 blouflashdb

Thanks for your PR, @blouflashdb. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

ghost avatar Oct 15 '22 14:10 ghost

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

blouflashdb avatar Oct 15 '22 15:10 blouflashdb

The SignalR client also targets .NET Framework, which doesn't have that attribute.

To work around this:

  1. Copy the attribute's source code from StringSyntaxAttribute.cs
  2. 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.
  3. 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.

JamesNK avatar Oct 16 '22 04:10 JamesNK

Thanks, I think I got it.

blouflashdb avatar Oct 16 '22 14:10 blouflashdb