Skip to content

Commit a4d213a

Browse files
authored
Report error when MetadataUpdateDeletedAttribute is applied manually (#80125)
1 parent 1b0d89c commit a4d213a

37 files changed

+354
-2
lines changed

src/Compilers/CSharp/Portable/CSharpResources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8196,4 +8196,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
81968196
<value>'MethodImplAttribute.Async' cannot be manually applied to methods. Mark the method 'async'.</value>
81978197
<remarks>'MethodImplAttribute.Async' and 'async' are not localizable.</remarks>
81988198
</data>
8199+
<data name="ERR_AttributeCannotBeAppliedManually" xml:space="preserve">
8200+
<value>'{0}' cannot be applied manually.</value>
8201+
</data>
81998202
</root>

src/Compilers/CSharp/Portable/Errors/ErrorCode.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,6 +2425,7 @@ internal enum ErrorCode
24252425
ERR_UnsupportedFeatureInRuntimeAsync = 9328,
24262426
ERR_ExtensionBlockCollision = 9329,
24272427
ERR_MethodImplAttributeAsyncCannotBeUsed = 9330,
2428+
ERR_AttributeCannotBeAppliedManually = 9331,
24282429

24292430
// Note: you will need to do the following after adding errors:
24302431
// 1) Update ErrorFacts.IsBuildOnlyDiagnostic (src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs)

src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,6 +2536,7 @@ or ErrorCode.ERR_MemberNameSameAsExtendedType
25362536
or ErrorCode.ERR_FeatureNotAvailableInVersion14
25372537
or ErrorCode.ERR_ExtensionBlockCollision
25382538
or ErrorCode.ERR_MethodImplAttributeAsyncCannotBeUsed
2539+
or ErrorCode.ERR_AttributeCannotBeAppliedManually
25392540
=> false,
25402541
};
25412542
#pragma warning restore CS8524 // The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value.

src/Compilers/CSharp/Portable/Symbols/Symbol_Attributes.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ protected void DecodeWellKnownAttribute(ref DecodeWellKnownAttributeArguments<At
230230
arguments.Diagnostics.DiagnosticBag.Add(ErrorCode.ERR_InvalidExperimentalDiagID, attrArgumentLocation);
231231
}
232232
}
233+
else if (arguments.Attribute.IsTargetAttribute(AttributeDescription.MetadataUpdateDeletedAttribute))
234+
{
235+
arguments.Diagnostics.DiagnosticBag.Add(ErrorCode.ERR_AttributeCannotBeAppliedManually, arguments.AttributeSyntaxOpt!.Location, args: [AttributeDescription.MetadataUpdateDeletedAttribute.FullName]);
236+
}
233237

234238
DecodeWellKnownAttributeImpl(ref arguments);
235239
}

src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)