Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

Add Validate method to ResourceIdentifier #35848

Open JoshLove-msft opened 1 year ago

JoshLove-msft commented 1 year ago

The ResourceIdentifier constructor does not do any validation, whereas the Parse method does. For libraries that take a resourceIdentifier, the library should validate the resourceIdentifier if it is used in constructing the request URI path, which is the case for Azure.Monitor.Query. There are a couple workaround today:

resourceIdentifier = ResourceIdentifier.Parse(resourceIdentifier.ToString())

where resourceIdentifier is the user input Or

// accessing Name will perform validation
_ = resourceIdentifier.Name

It would be nice if there was a method that could be called so that it is more clear how to do this.

JoshLove-msft commented 1 year ago

/cc @nisha-bhatia @m-nash