Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require SizeConst for UnmanagedType.ByValArray #68992

Merged
merged 13 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
jkoritzinsky marked this conversation as resolved.
Show resolved Hide resolved
</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:
Copy link
Contributor

@AlekseyTs AlekseyTs Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case ErrorCode.WRN_ByValArraySizeConstRequired:

Are we testing the level? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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