Skip to content

Commit

Permalink
Require SizeConst for UnmanagedType.ByValArray (#68992)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoritzinsky authored Jul 31, 2023
1 parent 312d583 commit aa308ec
Show file tree
Hide file tree
Showing 25 changed files with 213 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -7574,6 +7574,12 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="WRN_AddressOfInAsync_Title" xml:space="preserve">
<value>The '&amp;' operator should not be used on parameters or local variables in async methods.</value>
</data>
<data name="WRN_ByValArraySizeConstRequired" xml:space="preserve">
<value>Attribute parameter 'SizeConst' must be specified.</value>
</data>
<data name="WRN_ByValArraySizeConstRequired_Title" xml:space="preserve">
<value>Attribute parameter 'SizeConst' must be specified.</value>
</data>
<data name="ERR_BadStaticAfterUnsafe" xml:space="preserve">
<value>'static' modifier must precede 'unsafe' modifier.</value>
</data>
Expand Down
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,7 @@ internal enum ErrorCode
ERR_UnexpectedParameterList = 9122,
WRN_AddressOfInAsync = 9123,
WRN_CapturedPrimaryConstructorParameterInFieldInitializer = 9124,
WRN_ByValArraySizeConstRequired = 9125,

ERR_BadRefInUsingAlias = 9130,
ERR_BadUnsafeInUsingDirective = 9131,
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ internal static int GetWarningLevel(ErrorCode code)
switch (code)
{
case ErrorCode.WRN_AddressOfInAsync:
case ErrorCode.WRN_ByValArraySizeConstRequired:
// Warning level 8 is exclusively for warnings introduced in the compiler
// shipped with dotnet 8 (C# 12) and that can be reported for pre-existing code.
return 8;
Expand Down Expand Up @@ -2394,6 +2395,7 @@ internal static bool IsBuildOnlyDiagnostic(ErrorCode code)
case ErrorCode.WRN_TargetDifferentRefness:
case ErrorCode.ERR_OutAttrOnRefReadonlyParam:
case ErrorCode.WRN_RefReadonlyParameterDefaultValue:
case ErrorCode.WRN_ByValArraySizeConstRequired:
return false;
default:
// NOTE: All error codes must be explicitly handled in this switch statement
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/CSharp/Portable/Errors/MessageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,7 @@ protected override void ReportAttributeParameterRequired(DiagnosticBag diagnosti
}

public override int ERR_BadAssemblyName => (int)ErrorCode.ERR_BadAssemblyName;

public override int? WRN_ByValArraySizeConstRequired => (int)ErrorCode.WRN_ByValArraySizeConstRequired;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aa308ec

Please sign in to comment.