Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display custom warning for resource type with /providers/ #1943

Merged
merged 3 commits into from
Mar 19, 2021

Conversation

anthony-c-martin
Copy link
Member

Fixes #1941

var typeSegments = resourceType.TypeReference.Types;

if (typeSegments.Length > 2 &&
typeSegments.Where((type, i) => i > 0 && i < (typeSegments.Length - 1) && StringComparer.OrdinalIgnoreCase.Equals(type, "providers")).Any())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

providers [](start = 146, length = 9)

The only nested resource type I could find was subscriptions/providers in Microsoft.Resources (searched in the manifest repo). That is read-only, so it should be ok.

TextSpan,
DiagnosticLevel.Warning,
"BCP174",
$"Type validation is not available for resource types declared containing a \"/providers/\" segment. For type validation, please instead use the \"scope\" property. See https://aka.ms/BicepScopes for more information.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For type validation, please [](start = 117, length = 27)

Should we change "For type validation, please" to just "Please"?

Copy link
Member

@majastrz majastrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@anthony-c-martin anthony-c-martin enabled auto-merge (squash) March 19, 2021 18:28
@anthony-c-martin anthony-c-martin merged commit 33cc18c into main Mar 19, 2021
@anthony-c-martin anthony-c-martin deleted the antmarti/issue1941 branch March 19, 2021 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect and provide warning for usage of "/providers/" in the type string
2 participants