-
Notifications
You must be signed in to change notification settings - Fork 716
Support _ prefix in VersionByNamespaceConvention #1171
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
6a22d46
Update Dockerfile and workflows for .NET versioning and CodeQL actions
xavierjohn 96b23db
Enhance NamespaceParser to support '_' prefix for versioning and upda…
xavierjohn 3aae49e
Update TryParse documentation to clarify namespace identifier require…
xavierjohn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/dotnet/.devcontainer/base.Dockerfile | ||
|
|
||
| # [Choice] .NET version: 7.0, 6.0, 5.0 | ||
| ARG VARIANT="8.0" | ||
| # [Choice] .NET version: use "latest" or a specific version like "10.0" | ||
| ARG VARIANT="10.0" | ||
| FROM mcr.microsoft.com/vscode/devcontainers/dotnet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,7 +142,9 @@ | |
| /// <summary> | ||
| /// Attempts to parse an API version from the specified namespace identifier. | ||
| /// </summary> | ||
| /// <param name="identifier">The namespace identifier to parse.</param> | ||
| /// <param name="identifier">The namespace identifier to parse. The identifier must start with | ||
| /// 'v', 'V', or '_' followed by a digit. The '_' prefix supports folder names that start with | ||
| /// a number, which causes Visual Studio to prepend an underscore to the namespace.</param> | ||
| /// <param name="apiVersion">The parsed <see cref="ApiVersion">API version</see> or <c>null</c>.</param> | ||
| /// <returns>True if parsing is successful; otherwise, false.</returns> | ||
| protected virtual bool TryParse( Text identifier, out ApiVersion? apiVersion ) | ||
|
|
@@ -157,21 +159,36 @@ | |
| return false; | ||
| } | ||
|
|
||
| // 'v' | 'V' : [<year> : ['_'] : <month> : ['_'] : <day>] : ['_'] : [<major> ['_' : <minor>]] : ['_'] : [<status>] | ||
| // 'v' | 'V' | '_' : [<year> : ['_'] : <month> : ['_'] : <day>] : ['_'] : [<major> ['_' : <minor>]] : ['_'] : [<status>] | ||
| // | ||
| // - v1 | ||
| // - v1_1 | ||
| // - v2_0_Beta | ||
| // - v20180401 | ||
| // - v2018_04_01_1_1_Beta | ||
| // - _1 | ||
| // - _1_1 | ||
| // - _20180401 | ||
| // - _2018_04_01 | ||
| var ch = identifier[0]; | ||
|
|
||
| if ( ch != 'v' && ch != 'V' ) | ||
| if ( ch != 'v' && ch != 'V' && ch != '_' ) | ||
| { | ||
| apiVersion = default; | ||
| return false; | ||
| } | ||
|
|
||
| if ( ch == '_' ) | ||
| { | ||
| // '_' prefix requires the next character to be a digit; | ||
| // otherwise, it's just a regular identifier | ||
| if ( identifier.Length < 2 || !char.IsDigit( identifier[1] ) ) | ||
| { | ||
| apiVersion = default; | ||
| return false; | ||
| } | ||
| } | ||
|
Comment on lines
+181
to
+190
Check noticeCode scanning / CodeQL Nested 'if' statements can be combined Note
These 'if' statements can be combined.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It definitely shouldn't be nested, but I'm not even sure it's necessary for this to exist |
||
|
|
||
| #if NETSTANDARD | ||
| identifier = identifier.Substring( 1 ); | ||
| #else | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire branch of logic doesn't make sense nor is there a test for this use case. What is this scenario? The only possibilities here are
_,v, orV, none of which will parse as a validApiVersion. If there were only 2 characters, the next letter would always have to be a digit anyway; for examplev1. This entire block doesn't appear to be necessary.