提交 ae2b6e58 编写于 作者: L leppie

Implements #6061

上级 d365aba2
...@@ -11711,7 +11711,7 @@ internal class CSharpResources { ...@@ -11711,7 +11711,7 @@ internal class CSharpResources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to &apos;{0}&apos; is not a recognized attribute location. All attributes in this block will be ignored.. /// Looks up a localized string similar to &apos;{0}&apos; is not a recognized attribute location. Valid attribute locations for this declaration are &apos;{1}&apos;. All attributes in this block will be ignored..
/// </summary> /// </summary>
internal static string WRN_InvalidAttributeLocation { internal static string WRN_InvalidAttributeLocation {
get { get {
......
...@@ -1758,7 +1758,7 @@ If such a class is used as a base class and if the deriving class defines a dest ...@@ -1758,7 +1758,7 @@ If such a class is used as a base class and if the deriving class defines a dest
<value>Not a valid attribute location for this declaration</value> <value>Not a valid attribute location for this declaration</value>
</data> </data>
<data name="WRN_InvalidAttributeLocation" xml:space="preserve"> <data name="WRN_InvalidAttributeLocation" xml:space="preserve">
<value>'{0}' is not a recognized attribute location. All attributes in this block will be ignored.</value> <value>'{0}' is not a recognized attribute location. Valid attribute locations for this declaration are '{1}'. All attributes in this block will be ignored.</value>
</data> </data>
<data name="WRN_InvalidAttributeLocation_Title" xml:space="preserve"> <data name="WRN_InvalidAttributeLocation_Title" xml:space="preserve">
<value>Not a recognized attribute location</value> <value>Not a recognized attribute location</value>
......
...@@ -462,6 +462,8 @@ private static bool MatchAttributeTarget(IAttributeTargetSymbol attributeTarget, ...@@ -462,6 +462,8 @@ private static bool MatchAttributeTarget(IAttributeTargetSymbol attributeTarget,
return isOwner; return isOwner;
} }
AttributeLocation allowedTargets = attributesOwner.AllowedAttributeLocations;
AttributeLocation explicitTarget = targetOpt.GetAttributeLocation(); AttributeLocation explicitTarget = targetOpt.GetAttributeLocation();
if (explicitTarget == AttributeLocation.None) if (explicitTarget == AttributeLocation.None)
{ {
...@@ -470,13 +472,12 @@ private static bool MatchAttributeTarget(IAttributeTargetSymbol attributeTarget, ...@@ -470,13 +472,12 @@ private static bool MatchAttributeTarget(IAttributeTargetSymbol attributeTarget,
{ {
//NOTE: ValueText so that we accept targets like "@return", to match dev10 (DevDiv #2591). //NOTE: ValueText so that we accept targets like "@return", to match dev10 (DevDiv #2591).
diagnostics.Add(ErrorCode.WRN_InvalidAttributeLocation, diagnostics.Add(ErrorCode.WRN_InvalidAttributeLocation,
targetOpt.Identifier.GetLocation(), targetOpt.Identifier.ValueText); targetOpt.Identifier.GetLocation(), targetOpt.Identifier.ValueText, allowedTargets.ToDisplayString());
} }
return false; return false;
} }
AttributeLocation allowedTargets = attributesOwner.AllowedAttributeLocations;
if ((explicitTarget & allowedTargets) == 0) if ((explicitTarget & allowedTargets) == 0)
{ {
// error: invalid target for symbol // error: invalid target for symbol
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册