Skip to content

Obtaining exports of static members should not instantiate the declaring type #593

@AArnott

Description

@AArnott

Consider the following MEF part:

class Some
{
   [Export]
   public static string Member => "Hi";
}

This is interesting because the exporting member is static. Before MEF obtains the value of this member, it instantiates the Some class, even though that isn't necessary for a static member.

We should change MEF to not activate the class and simply obtain the static member's value directly.

We should add unit tests for this case, covering static members of all supported types: fields, properties and methods.
The test should exercise obtaining the value and verify it matches the expected value.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions