Closed frankbryce closed 6 years ago
@frankbryce In which case the type is a generic type but index of "`" is -1?
@scott-xu I'm not sure, I no longer have that exact code because I worked around the issue. The next chance that I get I'll try to reproduce it and let you know.
ok thanks
In the function,
type.Name
is Builder
type.FullName
is "System.Collections.Immutable.ImmutableArray`1+Builder"Here is sample code where type.IsGenericType
is true
but index of "`" is -1.
class Program
{
static void Main()
{
var type = typeof (Generic<>.ClassWithinGeneric);
Console.WriteLine(type.IsGenericType); // True
Console.WriteLine(type.Name.IndexOf("`")); // -1
}
}
public class Generic<T>
{
public class ClassWithinGeneric { }
}
Happened to me as well. Here is an example:
public class MyGenericType<T>
{
public MyGenericType()
{
var lambda = (T element) => T == default(T);
// This lambda will be compiled to a generic class with full name
// like "MyGenericType`1+<>c", but short name just "<>c"
}
}
I'm liking the package but I ran into this issue.
On line 102 of file AbstractInterfaceBindingGenerator.cs, the string.SubString() method is called without first making sure that the IndexOf() call did not return -1. The following exception is thrown if the IndexOf() returns -1, which is not very useful when something went wrong with my Ninject bootstrapping.
"System.ArgumentOutOfRangeException: Length cannot be less than zero"
The call that I'm making which ultimately leads to this exception is the following.
kernel.Bind(x => x.FromAssembliesInPath(Directory.GetCurrentDirectory()) .SelectAllClasses().BindDefaultInterfaces());