Skip to content

Conversation

@JelleKerkstra
Copy link
Contributor

This PR resolves the DynamicProxyException Duplicate element: Castle.DynamicProxy.Generators.MetaMethod when generating a proxy that implements the following interfaces due to the nested classes.
In the current implementation, only the namespace, type name and method name are considered. In this PR, the declaring type names are also used when generating explicit interface implementations due to matching method names.

public static class OuterWrapper
{
	public static class InnerWrapperA
	{
		public interface ISharedName
		{
			void M();
		}
	}

	public static class InnerWrapperB
	{
		public interface ISharedName
		{
			void M();
		}
	}

	public static class InnerWrapperC
	{
		public interface ISharedName
		{
			void M();
		}
	}
}

@stakx
Copy link
Member

stakx commented Nov 23, 2025

@JelleKerkstra, apologies for the very long delay. I realise it has been more than a year since you submitted this PR. If you're no longer interested in this, that's OK, too. Let me know whether or not you'd like to proceed.

JelleKerkstra and others added 5 commits January 5, 2026 20:03
`string.Concat` can be up to twice as fast as using `StringBuilder`.
This change will nearly restore the original performance of that method,
with a small penalty due to the added `.IsNested` checks and more
precise representation of generic type arguments.
@stakx
Copy link
Member

stakx commented Jan 5, 2026

@JelleKerkstra, I haven't heard back from you, but I'd like to see this bug fix get merged. Since there was an issue in your proposed code changes with the fast path getting removed from SwitchToExplicitImplementationName, I added a few commits of my own to your PR to deal with that... I hope you don't mind. I am also adding a changelog entry crediting the bug fix to you, since you provided the original bug fix.

@stakx stakx changed the title Include DeclaringType.Name for nested types when generating explicit implementation names Fix DynamicProxyException ("duplicate element") due to DynamicProxy not accounting for outer type names of nested types Jan 5, 2026
@stakx stakx merged commit 1252d3d into castleproject:master Jan 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants