-
Notifications
You must be signed in to change notification settings - Fork 4k
AzDev - tell autorest-based modules from v3/v4 #28455
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
Conversation
Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
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.
Pull Request Overview
This PR introduces a new feature to the AzDev toolset that automatically detects and reports the AutoRest.PowerShell version (v3 or v4) used in AutoRest-based projects. The detected version is exposed as a new SubType
property in both the project model and Get-DevProject
cmdlet output, enabling users to easily group and filter projects by AutoRest version.
Key changes include:
- AutoRest.PowerShell version detection logic that parses YAML configurations in README.md files
- New
SubType
property added to project models to store the detected version - Enhanced YAML parsing capabilities with error handling and version mapping logic
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tools/AzDev/src/Services/YamlHelper.cs | Adds safe YAML deserialization method with exception handling |
tools/AzDev/src/Services/Conventions.cs | Implements version mapping logic for AutoRest.PowerShell versions |
tools/AzDev/src/Models/PSModels/PSProject.cs | Adds SubType property to PowerShell project model |
tools/AzDev/src/Models/Inventory/Project.cs | Adds SubType property to base project model |
tools/AzDev/src/Models/Inventory/AutoRestYamlConfig.cs | Enhances YAML config model to parse use-extension blocks |
tools/AzDev/src/Models/Inventory/AutoRestProject.cs | Implements AutoRest version detection and refactors configuration loading |
tools/AzDev/Tests/PSTests/InventoryTests.ps1 | Adds test to validate SubType property on AutoRest projects |
tools/AzDev/Tests/ModelTests/ProjectTests.cs | Adds comprehensive unit tests for version detection logic |
tools/AzDev/Tests/ModelTests/ModuleTests.cs | Updates existing tests to include README.md files |
tools/AzDev/Tests/HelperTests/YamlTests.cs | Updates YAML tests for directive property changes |
tools/AzDev/Tests/HelperTests/ConventionTests.cs | Adds tests for version mapping function |
tools/AzDev/README.md | Updates documentation with examples of new SubType functionality |
tools/AzDev/CHANGELOG.md | Documents the new feature |
tools/AzDev/AzDev/AzDev.format.ps1xml | Adds SubType column to default display format |
Comments suppressed due to low confidence (1)
tools/AzDev/src/Models/Inventory/AutoRestYamlConfig.cs:1
- Line 44 shows a removed property of type
IEnumerable<object>
but line 45 adds a property of the same name with typeobject
. This type change will break existing code that expectsDirective
to be enumerable. Consider keeping the original type or using a different property name.
// ----------------------------------------------------------------------------------
.Select(y => YamlHelper.TryDeserialize<AutoRestYamlConfig>(y, out var c) ? c : null) | ||
.Where(c => c != null)!; |
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.
The null-forgiving operator !
at the end of line 124 is unnecessary and potentially misleading since the Where(c => c != null)
filter guarantees no null values remain in the sequence. Remove the !
operator.
.Select(y => YamlHelper.TryDeserialize<AutoRestYamlConfig>(y, out var c) ? c : null) | |
.Where(c => c != null)!; | |
.Where(c => c != null); |
Copilot uses AI. Check for mistakes.
{ | ||
yamlBlocks.Add(match.Groups[1].Value.Trim()); | ||
var kvp = c.UseExtension.FirstOrDefault(k => k.Key.Replace("\"", string.Empty).Equals("@autorest/powershell", StringComparison.OrdinalIgnoreCase)); |
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.
The string replacement logic k.Key.Replace(\"\\\"
, string.Empty)` appears to be handling quoted keys in YAML. This should be handled by the YAML deserializer instead of manual string manipulation. Consider configuring the YAML deserializer to handle quotes properly.
var kvp = c.UseExtension.FirstOrDefault(k => k.Key.Replace("\"", string.Empty).Equals("@autorest/powershell", StringComparison.OrdinalIgnoreCase)); | |
var kvp = c.UseExtension.FirstOrDefault(k => k.Key.Equals("@autorest/powershell", StringComparison.OrdinalIgnoreCase)); |
Copilot uses AI. Check for mistakes.
Description
This pull request introduces a new feature to the AzDev toolset that enables detection and reporting of the AutoRest.PowerShell version (v3 or v4) used in AutoRest-based projects. This version is now surfaced as the
SubType
property in both the project model and theGet-DevProject
output, allowing users to easily group or filter projects by AutoRest version. The PR also adds comprehensive tests for this functionality and updates documentation and formatting to support the new property.Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.md
and reviewed the following information:ChangeLog.md
file(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
.## Upcoming Release
header in the past tense.ChangeLog.md
if no new release is required, such as fixing test case only.