You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have component-level unit tests that check that each individual component can be exported if the unit test supplies the correct imports. However, we don't have any integration-level tests that check that all of our exported objects can actually be created at runtime i.e. when VS loads and tries to resolve all of the MEF imports at runtime.
We only tend to find these types of errors when launching VS in debug mode, and when a MEF composition does occur at runtime it can be difficult to work out the root cause of the problem as a single missing import will cause all transitive imports to fail. Also, a MEF composition failure might not occur immediately - we might need to manually exercise some features to see a failure.
It would simplify and speed up debugging and troubleshooting if we had an integration-level test that checked the set of exports/imports e.g.
build a list of all of the SonarLint assemblies
walk the SonarLint assemblies looking for exported types
for each exported type, create a SingleObjectImporter and attempt a MEF composition
Notes:
we'd need to load all of the dependent assemblies too i.e. any framework or VS assemblies required to instantiate any of our exported types
we'd need to provide a dummy implementation of any VS exports such as SVsServiceProvider and perhaps some Team Explorer exports. Alternatively, we could skip checking some of our exported types.
Point (1) would add a lot of complexity in locating and loading the appropriate VS/.NET framework assembly.
A lighter-weight option would be to build a list of all available exports and then, instead of trying to actually instantiate each one, look at the types required in the ImportingConstructor to check that they are all available. That would be a less stringent test, but much easier to implement and faster to execute.
Also, the fact that some of our MEF classes fetch services in the constructor causes problems with multiple classes.
There is a separate ticket to address this: #4512.
The text was updated successfully, but these errors were encountered:
- partial. The basic test infrastructure works, but there are dozens of types that cannot be imported
because lots of our MEF constructors fetch services and perform work (see #4512)
Relates to #4825
- partial. The basic test infrastructure works, but there are dozens of types that cannot be imported
because lots of our MEF constructors fetch services and perform work (see SonarSource#4512)
Relates to SonarSource#4825
Description
We have component-level unit tests that check that each individual component can be exported if the unit test supplies the correct imports. However, we don't have any integration-level tests that check that all of our exported objects can actually be created at runtime i.e. when VS loads and tries to resolve all of the MEF imports at runtime.
We only tend to find these types of errors when launching VS in debug mode, and when a MEF composition does occur at runtime it can be difficult to work out the root cause of the problem as a single missing import will cause all transitive imports to fail. Also, a MEF composition failure might not occur immediately - we might need to manually exercise some features to see a failure.
It would simplify and speed up debugging and troubleshooting if we had an integration-level test that checked the set of exports/imports e.g.
SingleObjectImporter
and attempt a MEF compositionNotes:
SVsServiceProvider
and perhaps someTeam Explorer
exports. Alternatively, we could skip checking some of our exported types.Point (1) would add a lot of complexity in locating and loading the appropriate VS/.NET framework assembly.
A lighter-weight option would be to build a list of all available exports and then, instead of trying to actually instantiate each one, look at the types required in the
ImportingConstructor
to check that they are all available. That would be a less stringent test, but much easier to implement and faster to execute.Also, the fact that some of our MEF classes fetch services in the constructor causes problems with multiple classes.
There is a separate ticket to address this: #4512.
The text was updated successfully, but these errors were encountered: