Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update test template tests #49554

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

Merged
merged 2 commits into from
Jun 25, 2025

Conversation

mariam-abdulla
Copy link
Member

@mariam-abdulla mariam-abdulla commented Jun 25, 2025

This pull request refactors the RecordPackages method in DotnetNewTestTemplatesTests.cs to use a structured ComponentDetectionManifest format instead of a simple dictionary for tracking package versions. It also introduces new helper classes to model the manifest structure and updates the logic to handle existing manifests more robustly. Additionally, the packages.json file has been moved to a new directory, and the code now ensures proper serialization with camelCase naming.

Refactoring RecordPackages Method:

  • Replaced the dictionary-based approach for tracking package versions with a structured ComponentDetectionManifest format, including support for registrations and component details. [1] [2] [3]
  • Added logic to handle existing manifests gracefully, preventing overwriting when parsing fails, and only writing updates if changes are made. [1] [2]

Manifest Structure Enhancements:

  • Introduced helper classes (ComponentDetectionManifest, Registration, Component, NugetComponent) to model the manifest structure and added JSON serialization attributes for camelCase naming.

File Path Update:

  • Updated the PackagesJsonPath to point to the new directory test/TestPackages/packages.json, reflecting the relocation of the packages.json file.

New packages.json File:

  • Added an empty packages.json file in the test/TestPackages directory, adhering to the new ComponentDetectionManifest schema.

Minor Code Improvements:

  • Included System.Text.Json.Serialization for handling JSON serialization in the updated manifest structure.

@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 08:01
@mariam-abdulla mariam-abdulla requested a review from a team as a code owner June 25, 2025 08:01
Copy link
Contributor

@Copilot Copilot AI left a 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 refactors the RecordPackages logic in DotnetNewTestTemplatesTests.cs to use a structured Component Detection Manifest (JSON schema) instead of a simple version dictionary, moves the test packages file to a dedicated TestPackages directory, and introduces model classes for serialization.

  • Moved packages.json path to test/TestPackages and added an initial empty manifest file.
  • Replaced dictionary-based package version tracking with ComponentDetectionManifest and related types.
  • Updated serialization/deserialization logic and added guards to avoid overwriting on parse errors.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/dotnet-new.IntegrationTests/DotnetNewTestTemplatesTests.cs Reworked RecordPackages to use a manifest model and JSON attributes, added CreateNewManifest helper and nested classes
test/TestPackages/packages.json Added new empty manifest stub for tests
Comments suppressed due to low confidence (2)

test/dotnet-new.IntegrationTests/DotnetNewTestTemplatesTests.cs:348

  • The initializer [] is not valid for a List<Registration>. Use a proper list constructor, for example Registrations = new List<Registration>().
                []

test/dotnet-new.IntegrationTests/DotnetNewTestTemplatesTests.cs:310

  • You cannot assign through a null-conditional operator. Ensure Component and Nuget are non-null and then assign directly, e.g.: existingRegistration.Component.Nuget.Version = version;.
                        existingRegistration.Component?.Nuget?.Version = version;

@mariam-abdulla mariam-abdulla disabled auto-merge June 25, 2025 13:53
@mariam-abdulla mariam-abdulla enabled auto-merge (squash) June 25, 2025 14:20
@mariam-abdulla mariam-abdulla merged commit 9081d8f into main Jun 25, 2025
26 checks passed
@mariam-abdulla mariam-abdulla deleted the dev/mabdullah/update-test-templates-test branch June 25, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants