Skip to content

Require SizeConst for UnmanagedType.ByValArray - #68992

Merged
jkoritzinsky merged 13 commits into
dotnet:mainfrom
jkoritzinsky:sizeconst-byvalarray
Jul 31, 2023
Merged

jkoritzinsky merged 13 commits into
dotnet:mainfrom
jkoritzinsky:sizeconst-byvalarray

Conversation

@jkoritzinsky

@jkoritzinsky jkoritzinsky commented Jul 11, 2023 •

Copy link
Copy Markdown
Member

MarshalAsAttribute.SizeConst is required by all runtimes for UnmanagedType.ByValArray, so warn when it is not provided.

As mentioned below, we cannot make it an error due to back-compat.

Fixes #68988
Fixes dotnet/runtime#36134

…o require it when decoding instead of defaulting to length 1.
@jkoritzinsky
jkoritzinsky requested a review from a team as a code owner July 11, 2023 21:58
@ghost ghost added the untriaged Issues and PRs which have not yet been triaged by a lead label Jul 11, 2023

@jaredpar jaredpar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This cannot be an error

@jaredpar jaredpar modified the milestones: 17.8, Backlog Jul 12, 2023
@jkoritzinsky
jkoritzinsky dismissed jaredpar’s stale review July 18, 2023 20:50

The diagnostic is now a warning.

@jkoritzinsky

Copy link
Copy Markdown
Member Author

@jaredpar @AlekseyTs can I get another review pass?

switch (code)
{
case ErrorCode.WRN_AddressOfInAsync:
case ErrorCode.WRN_ByValArraySizeConstRequired:

@AlekseyTs AlekseyTs Jul 20, 2023 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@AlekseyTs

AlekseyTs commented Jul 20, 2023 •

Copy link
Copy Markdown
Contributor
    public void NativeTypeFixedArray()

Instead of modifying attributes in this test, we should assert the warnings. Otherwise we are not verifying metadata emitted for the affected scenario.


In reply to: 1644180537


Refers to: src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_MarshalAs.cs:565 in 60d535c. [](commit_id = 60d535c, deletion_comment = False)

@AlekseyTs

Copy link
Copy Markdown
Contributor
    public void NativeTypeFixedArray()

Also should test that the warning is suppressed if CompilationOptions.WarningLever < 8 is used.


In reply to: 1644180537


Refers to: src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_MarshalAs.cs:565 in 60d535c. [](commit_id = 60d535c, deletion_comment = False)

@AlekseyTs

AlekseyTs commented Jul 20, 2023 •

Copy link
Copy Markdown
Contributor
    public void NativeTypeFixedArray()

We should check if any diagnostic is reported for similar VB test.


In reply to: 1644195564


Refers to: src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_MarshalAs.cs:565 in 60d535c. [](commit_id = 60d535c, deletion_comment = False)

@AlekseyTs

Copy link
Copy Markdown
Contributor

Done with review pass (commit 10)

@jkoritzinsky
jkoritzinsky requested a review from AlekseyTs July 26, 2023 00:02

@AlekseyTs AlekseyTs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM (commit 12)

@AlekseyTs

Copy link
Copy Markdown
Contributor

@dotnet/roslyn-compiler For the second review

@jkoritzinsky
jkoritzinsky requested a review from a team July 26, 2023 19:57
@jaredpar jaredpar modified the milestones: Backlog, 17.8 Jul 31, 2023
@jaredpar

Copy link
Copy Markdown
Member

@jkoritzinsky can you get the merge conflicts fixed and then we should be good to merge.

@jkoritzinsky
jkoritzinsky enabled auto-merge (squash) July 31, 2023 16:57
@jkoritzinsky
jkoritzinsky merged commit aa308ec into dotnet:main Jul 31, 2023
@ghost ghost modified the milestones: 17.8, Next Jul 31, 2023
@jkoritzinsky
jkoritzinsky deleted the sizeconst-byvalarray branch July 31, 2023 18:27
@dibarbet dibarbet modified the milestones: Next, 17.8 P2 Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

4 participants