Skip to content

Fix JSON serialization for Result-derived classes#642

Open
felickz wants to merge 1 commit intomicrosoft:mainfrom
forks-felickz:main
Open

Fix JSON serialization for Result-derived classes#642
felickz wants to merge 1 commit intomicrosoft:mainfrom
forks-felickz:main

Conversation

@felickz
Copy link

@felickz felickz commented Feb 18, 2026

* Initial plan

* Initial investigation of exporttags JSON bug

Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>

* Fix exporttags JSON output bug by using runtime type for serialization

Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>

* Improve test to exercise actual JsonWriter code path

- Modified ExportJsonSerialization test to use JsonWriter.WriteResults
- Added InternalsVisibleTo attribute to expose JsonWriter to tests
- Test now validates production code path instead of direct serialization

Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>

* Revert nuget.config to use Azure DevOps feed

Per repo guidance, nuget.config changes should not be checked in.
Reverting to original Azure DevOps feed configuration.

Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: felickz <1760475+felickz@users.noreply.github.com>
Copy link
Contributor

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 pull request fixes a JSON serialization bug in the exporttags command where only the appVersion field was being output instead of all tag data. The root cause was that JsonSerializer.Serialize was using the compile-time base type (Result) instead of the runtime derived type, causing only base class properties to be serialized.

Changes:

  • Fixed JSON serialization to use runtime type (result.GetType()) for Result-derived classes (TagDiffResult, ExportTagsResult, VerifyRulesResult)
  • Added comprehensive test that exercises the actual JsonWriter production code path
  • Added InternalsVisibleTo attribute to enable testing internal CLI components

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
AppInspector.CLI/Writers/JsonWriter.cs Fixed serialization to pass runtime type parameter, ensuring derived class properties are included in JSON output
AppInspector.Tests/Commands/TestExportTagsCmd.cs Added test that validates JSON serialization through production JsonWriter code path
AppInspector.CLI/Properties/AssemblyInfo.cs Added InternalsVisibleTo attribute to expose internal JsonWriter class to test project

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.

Bug: exporttags with --output-file-format json outputs only appVersion, no tags

2 participants

Comments