Description:
Applying a GenerateFactory to a class with a static constructor leads wrong contracts being generated.
What Happens
The generated interface does not contain a member for the instance constructor. This following class
[GenerateFactory]
public class StaticConstructor
{
static StaticConstructor()
{}
public StaticConstructor(string parameter)
{ }
}
Will generate this interface:
public interface IStaticConstructorFactory
{
/// <summary>
/// Creates a new instance of <see cref="Ninject.Extension.AutoFactories.Sandbox.StaticConstructor"/>
/// </summary>
global::Ninject.Extension.AutoFactories.Sandbox.StaticConstructor Create();
}
and this implementation:
internal sealed partial class StaticConstructorFactory : global::Ninject.Extension.AutoFactories.Sandbox.IStaticConstructorFactory
{
private readonly global::Ninject.Syntax.IResolutionRoot m_resolutionRoot;
public StaticConstructorFactory(global::Ninject.Syntax.IResolutionRoot resolutionRoot)
{
m_resolutionRoot = resolutionRoot;
}
/// <summary>
/// Creates a new instance of <see cref="Ninject.Extension.AutoFactories.Sandbox.StaticConstructor"/>
/// </summary>
public global::Ninject.Extension.AutoFactories.Sandbox.StaticConstructor Create()
{
IParameter[] parameters = new IParameter[]
{
};
global::Ninject.Extension.AutoFactories.Sandbox.StaticConstructor instance = m_resolutionRoot.Get<global::Ninject.Extension.AutoF
return instance;
}
/// <summary>
/// Creates a new instance of <see cref="Ninject.Extension.AutoFactories.Sandbox.StaticConstructor"/>
/// </summary>
public global::Ninject.Extension.AutoFactories.Sandbox.StaticConstructor Create(global::string parameter)
{
IParameter[] parameters = new IParameter[]
{
new ConstructorArgument("parameter", parameter)
};
global::Ninject.Extension.AutoFactories.Sandbox.StaticConstructor instance = m_resolutionRoot.Get<global::Ninject.Extension.AutoF
return instance;
}
}
What Should Happen
A single constructor is generated taking a single string parameter.
Description: Applying a
GenerateFactory
to a class with a static constructor leads wrong contracts being generated.What Happens
The generated interface does not contain a member for the instance constructor. This following class
Will generate this interface:
and this implementation:
What Should Happen
A single constructor is generated taking a single
string
parameter.