Skip to content

Commit

Permalink
Merge pull request #475 from zapov/master
Browse files Browse the repository at this point in the history
Repro test for interface ordering issue
  • Loading branch information
jonorossi committed Apr 28, 2020
2 parents 6819f5c + f98227c commit 4ad38b6
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Castle.Core.Tests/DynamicProxy.Tests/MixinTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,17 @@ public void MixinWithSameInterface_InterfaceWithTarget_AdditionalInterfaces_Deri
var proxy = generator.CreateInterfaceProxyWithTarget(typeof(IService), new Type[] { typeof(IDerivedSimpleMixin) }, new ServiceImpl(), options, interceptor);
Assert.AreEqual(1, (proxy as ISimpleMixin).DoSomething());
}

[Test]
public void CanCreateMixinWithCaseSensitiveImplementationOrder()
{
ProxyGenerationOptions options = new ProxyGenerationOptions();
options.AddMixinInstance(new DomainWithMixin());
options.AddMixinInstance(new DomainsAs());

var proxy = generator.CreateClassProxy(typeof(MixinDomainObject), options, new object[] { "argument" });
Assert.IsInstanceOf(typeof(MixinDomainObject), proxy);
Assert.AreEqual("argument", ((MixinDomainObject)proxy).Name);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// 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.Mixins
{
using System;

public interface IDomainWithMixin
{
void DoSomething();
}
public interface IDomainsAs
{
void DoSomethingElse();
}

#if FEATURE_SERIALIZATION
[Serializable]
#endif
public class DomainWithMixin : IDomainWithMixin
{
public void DoSomething() { }
}

#if FEATURE_SERIALIZATION
[Serializable]
#endif
public class DomainsAs : IDomainsAs
{
public void DoSomethingElse() { }
}

public class MixinDomainObject
{
public readonly string Name;
public MixinDomainObject(string name)
{
this.Name = name;
}
}
}
2 changes: 1 addition & 1 deletion src/Castle.Core/DynamicProxy/MixinData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public MixinData(IEnumerable<object> mixinInstances)
}
}

sortedMixedInterfaceTypes.Sort((x, y) => x.FullName.CompareTo(y.FullName));
sortedMixedInterfaceTypes.Sort((x, y) => String.CompareOrdinal(x.FullName, y.FullName));

for (var i = 0; i < sortedMixedInterfaceTypes.Count; i++)
{
Expand Down

0 comments on commit 4ad38b6

Please sign in to comment.