提交 069419c1 编写于 作者: S shyamn

Disallow ComAliasNameAttribute from getting emitted on parameters in cases...

Disallow ComAliasNameAttribute from getting emitted on parameters in cases where user invokes implement interface refactoring to implement a COM interface. (changeset 1261481)
上级 f35e0dc4
...@@ -85,5 +85,10 @@ public static INamedTypeSymbol CoClassType(this Compilation compilation) ...@@ -85,5 +85,10 @@ public static INamedTypeSymbol CoClassType(this Compilation compilation)
{ {
return compilation.GetTypeByMetadataName("System.Runtime.InteropServices.CoClassAttribute"); return compilation.GetTypeByMetadataName("System.Runtime.InteropServices.CoClassAttribute");
} }
public static INamedTypeSymbol ComAliasNameAttributeType(this Compilation compilation)
{
return compilation.GetTypeByMetadataName("System.Runtime.InteropServices.ComAliasNameAttribute");
}
} }
} }
\ No newline at end of file
...@@ -168,6 +168,42 @@ public static IMethodSymbol RenameParameters(this IMethodSymbol method, IList<st ...@@ -168,6 +168,42 @@ public static IMethodSymbol RenameParameters(this IMethodSymbol method, IList<st
return updatedMethod.RenameParameters(parameterNames); return updatedMethod.RenameParameters(parameterNames);
} }
public static IMethodSymbol RemoveAttributeFromParameters(
this IMethodSymbol method, INamedTypeSymbol attributeType,
IList<SyntaxNode> statements = null, IList<SyntaxNode> handlesExpressions = null)
{
if (attributeType == null)
{
return method;
}
var someParameterHasAttribute = method.Parameters
.Where(m => m.GetAttributes().Where(a => a.AttributeClass.Equals(attributeType)).Any())
.Any();
if (!someParameterHasAttribute)
{
return method;
}
return CodeGenerationSymbolFactory.CreateMethodSymbol(
method.ContainingType,
method.GetAttributes(),
method.DeclaredAccessibility,
method.GetSymbolModifiers(),
method.ReturnType,
method.ExplicitInterfaceImplementations.FirstOrDefault(),
method.Name,
method.TypeParameters,
method.Parameters.Select(p =>
CodeGenerationSymbolFactory.CreateParameterSymbol(
p.GetAttributes().Where(a => !a.AttributeClass.Equals(attributeType)).ToList(),
p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional,
p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null)).ToList(),
statements,
handlesExpressions,
method.GetReturnTypeAttributes());
}
public static bool? IsMoreSpecificThan(this IMethodSymbol method1, IMethodSymbol method2) public static bool? IsMoreSpecificThan(this IMethodSymbol method1, IMethodSymbol method2)
{ {
var p1 = method1.Parameters; var p1 = method1.Parameters;
......
...@@ -33,5 +33,39 @@ public static IPropertySymbol RenameParameters(this IPropertySymbol property, IL ...@@ -33,5 +33,39 @@ public static IPropertySymbol RenameParameters(this IPropertySymbol property, IL
property.SetMethod, property.SetMethod,
property.IsIndexer); property.IsIndexer);
} }
public static IPropertySymbol RemoveAttributeFromParameters(
this IPropertySymbol property, INamedTypeSymbol attributeType)
{
if (attributeType == null)
{
return property;
}
var someParameterHasAttribute = property.Parameters
.Where(p => p.GetAttributes().Where(a => a.AttributeClass.Equals(attributeType)).Any())
.Any();
if (!someParameterHasAttribute)
{
return property;
}
return CodeGenerationSymbolFactory.CreatePropertySymbol(
property.ContainingType,
property.GetAttributes(),
property.DeclaredAccessibility,
property.GetSymbolModifiers(),
property.Type,
property.ExplicitInterfaceImplementations.FirstOrDefault(),
property.Name,
property.Parameters.Select(p =>
CodeGenerationSymbolFactory.CreateParameterSymbol(
p.GetAttributes().Where(a => !a.AttributeClass.Equals(attributeType)).ToList(),
p.RefKind, p.IsParams, p.Type, p.Name, p.IsOptional,
p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null)).ToList(),
property.GetMethod,
property.SetMethod,
property.IsIndexer);
}
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册