Skip to content

Match versioned OS platform attributes in CoreCLR PInvokeCollector, add regression test - #132332

Open
akoeplinger with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-coreclr-collector-platform-attributes
Open

Match versioned OS platform attributes in CoreCLR PInvokeCollector, add regression test#132332
akoeplinger with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-coreclr-collector-platform-attributes

Conversation

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #132300: the CoreCLR generator's platform-attribute filter still compared SupportedOSPlatform/UnsupportedOSPlatform strings to _targetOS with exact equality, so versioned attributes like [SupportedOSPlatform("browser1.0")] were treated as non-matching on that path (mono's collector was already fixed).

CoreCLR collector fix

  • Duplicated the MatchesTargetOS helper (with the NETFRAMEWORK conditional for net472) into src/tasks/WasmAppBuilder/coreclr/PInvokeCollector.cs, per maintainer preference to keep the collectors independent rather than share code.
  • EvaluatePlatformAttributes now calls MatchesTargetOS instead of exact string comparison for both attributes.
  • src/tasks/WasmAppBuilder/mono/PInvokeCollector.cs is unchanged.
if (cattr.AttributeType.FullName == "System.Runtime.Versioning.UnsupportedOSPlatformAttribute" &&
    cattr.ConstructorArguments.Count > 0 &&
    MatchesTargetOS(cattr.ConstructorArguments[0].Value?.ToString()))
{
    return PlatformSupport.Unsupported;
}

Regression test

  • Added VersionedOSPlatformPInvokeIsIncluded to PInvokeTableGeneratorTests in src/mono/wasm/Wasm.Build.Tests.
  • New test asset declares a P/Invoke annotated [SupportedOSPlatform("browser1.0")] (must match TargetOS=browser) alongside one annotated [SupportedOSPlatform("windows1.0")] (must not match).
  • Asserts the browser-versioned entry is present in the generated pinvoke table and the windows-versioned one is absent, then runs the app to confirm the included P/Invoke is callable at runtime.

Copilot AI lite review requested due to automatic review settings August 14, 2026 17:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
16 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

…ession test

Co-authored-by: akoeplinger <1376924+akoeplinger@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 14, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

Copilot AI changed the title [WIP] Fix CoreCLR collector to match versioned OS platform attributes Match versioned OS platform attributes in CoreCLR PInvokeCollector, add regression test Aug 14, 2026
Copilot AI requested a review from akoeplinger August 14, 2026 18:16
@akoeplinger
akoeplinger marked this pull request as ready for review August 14, 2026 18:58
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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.

4 participants