-
Notifications
You must be signed in to change notification settings - Fork 90
Fix static member exports to not instantiate declaring type #594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
3d002e1
e660673
17f767f
63bfb57
c4ecf24
4648648
1c817b6
5c5690a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "sdk": { | ||
| "version": "8.0.116", | ||
| "version": "9.0.300", | ||
| "rollForward": "patch", | ||
| "allowPrerelease": false | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ namespace Microsoft.VisualStudio.Composition.Tests | |
| using Xunit; | ||
| using CompositionFailedException = Microsoft.VisualStudio.Composition.CompositionFailedException; | ||
| using MefV1 = System.ComponentModel.Composition; | ||
| using MefV2 = System.Composition; | ||
|
|
||
| [Trait("Static", "")] | ||
| public class StaticMemberExportsTests | ||
|
|
@@ -212,12 +213,15 @@ public ClassWithStaticMemberExports() | |
| } | ||
|
|
||
| [MefV1.Export("StaticField")] | ||
| [MefV2.Export("StaticField")] | ||
| public static string StaticField = "StaticFieldValue"; | ||
|
|
||
| [MefV1.Export("StaticProperty")] | ||
| [MefV2.Export("StaticProperty")] | ||
| public static string StaticProperty => "StaticPropertyValue"; | ||
|
|
||
| [MefV1.Export("StaticMethod")] | ||
| [MefV2.Export("StaticMethod")] | ||
AArnott marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public static string StaticMethod() => "StaticMethodValue"; | ||
| } | ||
|
|
||
|
|
@@ -238,13 +242,15 @@ public ClassWithMixedExports() | |
| } | ||
|
|
||
| [MefV1.Export("StaticMixed")] | ||
| [MefV2.Export("StaticMixed")] | ||
AArnott marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public static string StaticExport = "StaticValue"; | ||
|
|
||
| [MefV1.Export("InstanceMixed")] | ||
| [MefV2.Export("InstanceMixed")] | ||
| public string InstanceExport => "InstanceValue"; | ||
| } | ||
|
|
||
| [MefFact(CompositionEngines.V3EmulatingV1, typeof(ClassWithStaticMemberExports))] | ||
| [MefFact(CompositionEngines.V1Compat | CompositionEngines.V2Compat | CompositionEngines.V3EmulatingV1 | CompositionEngines.V3EmulatingV2, typeof(ClassWithStaticMemberExports))] | ||
| public void StaticFieldExportDoesNotInstantiateClass(IContainer container) | ||
| { | ||
| ClassWithStaticMemberExports.ConstructorCalled = false; | ||
|
|
@@ -253,7 +259,7 @@ public void StaticFieldExportDoesNotInstantiateClass(IContainer container) | |
| Assert.False(ClassWithStaticMemberExports.ConstructorCalled, "Constructor should not be called for static field export"); | ||
| } | ||
|
|
||
| [MefFact(CompositionEngines.V3EmulatingV1, typeof(ClassWithStaticMemberExports))] | ||
| [MefFact(CompositionEngines.V1Compat | CompositionEngines.V2Compat | CompositionEngines.V3EmulatingV1 | CompositionEngines.V3EmulatingV2, typeof(ClassWithStaticMemberExports))] | ||
| public void StaticPropertyExportDoesNotInstantiateClass(IContainer container) | ||
| { | ||
| ClassWithStaticMemberExports.ConstructorCalled = false; | ||
|
|
@@ -262,7 +268,7 @@ public void StaticPropertyExportDoesNotInstantiateClass(IContainer container) | |
| Assert.False(ClassWithStaticMemberExports.ConstructorCalled, "Constructor should not be called for static property export"); | ||
| } | ||
|
|
||
| [MefFact(CompositionEngines.V3EmulatingV1, typeof(ClassWithStaticMemberExports))] | ||
| [MefFact(CompositionEngines.V1Compat | CompositionEngines.V2Compat | CompositionEngines.V3EmulatingV1 | CompositionEngines.V3EmulatingV2, typeof(ClassWithStaticMemberExports))] | ||
|
||
| public void StaticMethodExportDoesNotInstantiateClass(IContainer container) | ||
| { | ||
| ClassWithStaticMemberExports.ConstructorCalled = false; | ||
|
|
@@ -271,7 +277,7 @@ public void StaticMethodExportDoesNotInstantiateClass(IContainer container) | |
| Assert.False(ClassWithStaticMemberExports.ConstructorCalled, "Constructor should not be called for static method export"); | ||
| } | ||
|
|
||
| [MefFact(CompositionEngines.V3EmulatingV1, typeof(ClassWithMixedExports))] | ||
| [MefFact(CompositionEngines.V1Compat | CompositionEngines.V2Compat | CompositionEngines.V3EmulatingV1 | CompositionEngines.V3EmulatingV2, typeof(ClassWithMixedExports))] | ||
| public void StaticExportInMixedClassDoesNotInstantiateClass(IContainer container) | ||
| { | ||
| ClassWithMixedExports.ConstructorCalled = false; | ||
|
|
@@ -280,7 +286,7 @@ public void StaticExportInMixedClassDoesNotInstantiateClass(IContainer container | |
| Assert.False(ClassWithMixedExports.ConstructorCalled, "Constructor should not be called when accessing only static export"); | ||
| } | ||
|
|
||
| [MefFact(CompositionEngines.V3EmulatingV1, typeof(ClassWithMixedExports))] | ||
| [MefFact(CompositionEngines.V1Compat | CompositionEngines.V2Compat | CompositionEngines.V3EmulatingV1 | CompositionEngines.V3EmulatingV2, typeof(ClassWithMixedExports))] | ||
| public void InstanceExportInMixedClassDoesInstantiateClass(IContainer container) | ||
| { | ||
| ClassWithMixedExports.ConstructorCalled = false; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.