Skip to content

fix(codegen): preserve enum members with framework refs - #7

Open
slobber wants to merge 1 commit into
pjanec:mainfrom
slobber:codex/fix-enum-codegen
Open

slobber wants to merge 1 commit into
pjanec:mainfrom
slobber:codex/fix-enum-codegen

Conversation

@slobber

@slobber slobber commented Nov 5, 2026

Copy link
Copy Markdown

Fixes #6.

Problem

When MSBuild passes framework reference assemblies to the code generator, SchemaDiscovery also adds runtime assemblies (System.Private.CoreLib and the rest of TRUSTED_PLATFORM_ASSEMBLIES). Roslyn then fails to resolve enum member constants, leaving EnumMembers empty. The generated IDL enum has no members and idlc fails.

This was reproduced from a net10.0 project consuming the net8.0 package, with an enum equivalent to the ValueTypeDiscriminator used by a downstream schema.

Fix

  • Detect whether referencePaths already contains Microsoft.NETCore.App.Ref.
  • When framework references are present, use them without mixing in runtime framework assemblies.
  • Keep the existing runtime-assembly fallback for callers that do not provide framework references.

Regression test

Added FrameworkReferenceEnumTests covering the ValueTypeDiscriminator shape with a framework reference pack. Before the fix, the test fails because EnumMembers is empty; after the fix, all members and values are retained.

Verification

  • Regression test passes.
  • Full CycloneDDS.CodeGen.Tests suite passes: 212/212.
  • A downstream net10.0 project using the enum and package 1.2.20 compiles with the patched generator.
  • Project target frameworks remain net8.0; no TFM change is included.

MSBuild supplies Microsoft.NETCore.App.Ref reference assemblies for the target framework. Do not mix them with runtime framework assemblies, which prevents Roslyn from resolving enum constants and produces empty IDL enums.
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.

Code generation emits empty IDL enums when framework reference assemblies are supplied

1 participant