-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicit interface implementation name collisions
When a proxy is made to implement the same generic interface more than twice, and that generic interface contains a method that does not use any generic type parameters, this can be result in a name collision. This would happen e.g. with a proxy implementing `IObserver<T>` three times. DynamicProxy does check for member name collisions, and when such a one is detected, it switches to explicit interface implementation and prefixes the member name with the generic interface type name. For the above example, this will add the following methods to the proxy: * OnCompleted * IObserver`1.OnCompleted * IObserver`1.OnCompleted It is clearly not sufficient to exclude the concrete type arguments and use only the number of type parameters. This commit changes the naming of explicitly implemented interface methods such that they are unique by including the generic type arguments. For example: * OnCompleted * IObserver`1[Boolean].OnCompleted * IObserver`1[Int32].OnCompleted
- Loading branch information
Showing
4 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Castle.Core.Tests/Interfaces/IGenericWithNonGenericMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2004-2010 Castle Project - http://www.castleproject.org/ | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace Castle.DynamicProxy.Tests.Interfaces | ||
{ | ||
public interface IGenericWithNonGenericMethod<T> | ||
{ | ||
void DoSomething(); | ||
} | ||
|
||
public interface IGenericWithNonGenericMethod<T1, T2> | ||
{ | ||
void DoSomething(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters