提交 176388aa 编写于 作者: S shyamn

Disallow COMAliasName attributes from showing up in code generated by the...

Disallow COMAliasName attributes from showing up in code generated by the 'Implement Interface' code fix even when the attribute is applied on the return type of the interface method. (changeset 1318851)
上级 8980c93e
......@@ -168,7 +168,7 @@ public static IMethodSymbol RenameParameters(this IMethodSymbol method, IList<st
return updatedMethod.RenameParameters(parameterNames);
}
public static IMethodSymbol RemoveAttributeFromParameters(
public static IMethodSymbol RemoveAttributeFromParametersAndReturnType(
this IMethodSymbol method, INamedTypeSymbol attributeType,
IList<SyntaxNode> statements = null, IList<SyntaxNode> handlesExpressions = null)
{
......@@ -178,9 +178,12 @@ public static IMethodSymbol RenameParameters(this IMethodSymbol method, IList<st
}
var someParameterHasAttribute = method.Parameters
.Where(m => m.GetAttributes().Where(a => a.AttributeClass.Equals(attributeType)).Any())
.Any();
if (!someParameterHasAttribute)
.Any(m => m.GetAttributes().Any(a => a.AttributeClass.Equals(attributeType)));
var returnTypeHasAttribute = method.GetReturnTypeAttributes()
.Any(a => a.AttributeClass.Equals(attributeType));
if (!someParameterHasAttribute && !returnTypeHasAttribute)
{
return method;
}
......@@ -201,7 +204,7 @@ public static IMethodSymbol RenameParameters(this IMethodSymbol method, IList<st
p.HasExplicitDefaultValue, p.HasExplicitDefaultValue ? p.ExplicitDefaultValue : null)).ToList(),
statements,
handlesExpressions,
method.GetReturnTypeAttributes());
method.GetReturnTypeAttributes().Where(a => !a.AttributeClass.Equals(attributeType)).ToList());
}
public static bool? IsMoreSpecificThan(this IMethodSymbol method1, IMethodSymbol method2)
......
......@@ -4,7 +4,6 @@
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Shared.Extensions
{
......@@ -43,8 +42,7 @@ public static IPropertySymbol RenameParameters(this IPropertySymbol property, IL
}
var someParameterHasAttribute = property.Parameters
.Where(p => p.GetAttributes().Where(a => a.AttributeClass.Equals(attributeType)).Any())
.Any();
.Any(p => p.GetAttributes().Any(a => a.AttributeClass.Equals(attributeType)));
if (!someParameterHasAttribute)
{
return property;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册