Skip to content

Commit 46101a5

Browse files
committed
Fixed #26
1 parent 588d5be commit 46101a5

5 files changed

Lines changed: 18 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [3.0.0-beta1]
88

99
### Added
1010
- Support .NET Standard 2.0
1111

1212
### Changed
1313
- Spelling: renamed "NonePublic" to "NonPublic"
1414

15+
### Fixed
16+
- `GetNameWithoutGenericPart` Throws `SubString` exception [#26](https://github.com/ninject/Ninject.Extensions.Conventions/issues/26)
17+
1518
### Removed
1619
- .NET 3.5, .NET 4.0 and Silverlight
1720

src/Ninject.Extensions.Conventions.Test/BindingGenerators/DefaultInterfaceBindingGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void InterfacesWithTheSameNameAreBound()
7171
[Fact]
7272
public void GenericInterfacesWithTheSameNameAreBound()
7373
{
74-
var type = typeof(Bar<int>);
74+
var type = typeof(ParentBar<int>.Bar<int>);
7575
var interfaces = new[] { typeof(IFoo), typeof(IBar), typeof(IBar<int>), typeof(IBar<>) };
7676
var expectedInterfaes = interfaces.Where(i => i.Name.StartsWith("IBar"));
7777
this.bindableInterfaceSelectorMock.Setup(s => s.GetBindableInterfaces(type)).Returns(interfaces);

src/Ninject.Extensions.Conventions.Test/BindingGenerators/DefaultInterfacesBindingGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void InterfacesContainedInClassesNameAreBound()
7878
[Fact]
7979
public void GenericInterfacesWithTheSameNameAreBound()
8080
{
81-
var type = typeof(Bar<int>);
81+
var type = typeof(ParentBar<int>.Bar<int>);
8282
var interfaces = new[] { typeof(IFoo), typeof(IBar), typeof(IBar<int>), typeof(IBar<>) };
8383
var expectedInterfaces = interfaces.Where(i => i.Name.StartsWith("IBar"));
8484
this.bindableInterfaceSelectorMock.Setup(s => s.GetBindableInterfaces(type)).Returns(interfaces);

src/Ninject.Extensions.Conventions.Test/Fakes/Bar.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121

2222
namespace Ninject.Extensions.Conventions.Fakes
2323
{
24-
public class Bar<T> : IBar<T>, IBar, IBar<int, int>
24+
public class ParentBar<T>
2525
{
26+
public class Bar<T> : IBar<T>, IBar, IBar<int, int>
27+
{
28+
}
2629
}
2730
}

src/Ninject.Extensions.Conventions/BindingGenerators/AbstractInterfaceBindingGenerator.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ protected static string GetNameWithoutGenericPart(Type type)
8585
}
8686

8787
var genericMarkerPosition = name.IndexOf("`", StringComparison.Ordinal);
88-
return name.Substring(0, genericMarkerPosition);
88+
if (genericMarkerPosition > -1)
89+
{
90+
return name.Substring(0, genericMarkerPosition);
91+
}
92+
else
93+
{
94+
return name;
95+
}
8996
}
9097
}
9198
}

0 commit comments

Comments
 (0)