machine / machine.specifications

Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
MIT License
885 stars 178 forks source link

System.MissingMethodException when an abstract class inherits class which implements IAssemblyContext #387

Closed niclasahlqvist closed 5 years ago

niclasahlqvist commented 5 years ago

When AssemblyRunner invokes OnAssemblyStart via reflection on an abstract class instance an exception is thrown. Only concrete implementations of IAssemblyContext should have its OnAssemblyStart method invoked

[error]Error: Machine Specifications Visual Studio Test Adapter - Fatal error while executing test.

[error]System.MissingMethodException: Cannot create an abstract class.

[error] at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)

[error] at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

[error] at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

[error] at System.Activator.CreateInstance(Type type, Boolean nonPublic)

[error] at System.Activator.CreateInstance(Type type)

[error] at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()

niclasahlqvist commented 5 years ago

I have fix which excludes abstract types when scanning for implementations of IAssemblyContext which I'll make a PR for.