-
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.
Avoid name collisions for properties & events, too
- Loading branch information
Showing
8 changed files
with
177 additions
and
35 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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 | ||
{ | ||
using System; | ||
|
||
public interface IGenericWithEvent<T> | ||
{ | ||
event EventHandler SomeEvent; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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 IGenericWithProperty<T> | ||
{ | ||
object SomeProperty { get; set; } | ||
} | ||
} |
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
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
61 changes: 61 additions & 0 deletions
61
src/Castle.Core/DynamicProxy/Generators/MetaTypeElementUtil.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,61 @@ | ||
// Copyright 2004-2011 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.Generators | ||
{ | ||
using System; | ||
using System.Reflection; | ||
using System.Text; | ||
|
||
internal static class MetaTypeElementUtil | ||
{ | ||
[ThreadStatic] | ||
private static StringBuilder sharedNameBuilder; | ||
|
||
public static string CreateNameForExplicitImplementation(Type sourceType, string name) | ||
{ | ||
if (sharedNameBuilder == null) | ||
{ | ||
sharedNameBuilder = new StringBuilder(); | ||
} | ||
|
||
var nameBuilder = sharedNameBuilder; | ||
nameBuilder.Length = 0; | ||
nameBuilder.AppendNameOf(sourceType); | ||
nameBuilder.Append('.'); | ||
nameBuilder.Append(name); | ||
|
||
return nameBuilder.ToString(); | ||
} | ||
|
||
private static void AppendNameOf(this StringBuilder nameBuilder, Type type) | ||
{ | ||
nameBuilder.Append(type.Name); | ||
if (type.GetTypeInfo().IsGenericType) | ||
{ | ||
nameBuilder.Append('['); | ||
var genericTypeArguments = type.GetGenericArguments(); | ||
for (int i = 0, n = genericTypeArguments.Length; i < n; ++i) | ||
{ | ||
if (i > 0) | ||
{ | ||
nameBuilder.Append(','); | ||
} | ||
nameBuilder.AppendNameOf(genericTypeArguments[i]); | ||
} | ||
nameBuilder.Append(']'); | ||
} | ||
} | ||
} | ||
} |