Skip to content

Conversation

@drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Nov 23, 2025

This PR fixes two issues in VSMEF007 (added in #603 and not yet released):

  1. The previous code was treating unattributed properties on types as imports. It was re-using logic that applies to importing constructor parameters, which are implicitly imports even when unattributed. To fix this, we instruct the method that determines the contract as to whether implicit imports are relevant to the caller or not.
  2. The previous code oversimplified the concept of MEF contract identity. Parts are identified using a contract containing both type and name. The prior code would coalesce these into a single value, which could cause issues when a part had multiple imports with the same name but different contracts, or where a type name matched a contract name. Both of these conditions were found in dotnet/project-system.

The previous code was treating unattributed properties on types as imports. It was re-using logic that applies to importing constructor parameters, which are implicitly imports even when unattributed.

To fix this, we instruct the method that determines the contract as to whether implicit imports are relevant to the caller or not.
MEF uses both the contract type and name to identify a part. The prior code was essentially coalescing these into a single value when one was null. This meant that if the contract name matched a type name, then you could get a false positive for duplcate imports, where in fact the types differed.

This was observed in the dotnet/project-system repo.
@AArnott
Copy link
Member

AArnott commented Nov 24, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@drewnoakes
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 648 in repo microsoft/vs-mef

@AArnott
Copy link
Member

AArnott commented Nov 26, 2025

/azp run

@AArnott AArnott enabled auto-merge November 26, 2025 14:33
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@AArnott AArnott merged commit 4c83c76 into microsoft:main Nov 26, 2025
6 checks passed
@drewnoakes drewnoakes deleted the fix-VSMEF007 branch November 26, 2025 22:27
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.

2 participants