Skip to content

C#: Extract init only accessors from CIL #4821

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

Merged
merged 8 commits into from
Jan 7, 2021

Conversation

tamasvajk
Copy link
Contributor

@tamasvajk tamasvajk commented Dec 14, 2020

init accessors are normal set accessors in IL, except that there's a modreq applied to them. To extract this modreq or modopt this PR introduces a ModifiedType, which references the unmodified type, the modifier, and the isRequired flag. These types are not written to the trapfiles, which means that when a ModifiedType would be written to a trapfile, we need to get the underlying unmodified type and write that instead. This is a bit error prone, because I didn't yet find a clear specification on where these modifiers can show up, but it looks like there are not that many places (fields, properties, methods, parameters and function pointers). See first bullet point in this remark.

Still missing:

@github-actions github-actions bot added the C# label Dec 14, 2020
@tamasvajk tamasvajk force-pushed the feature/csharp9-cil-init-prop branch from 1050ebf to 50343da Compare December 17, 2020 12:16
@tamasvajk tamasvajk force-pushed the feature/csharp9-cil-init-prop branch from 50343da to dcbcc88 Compare December 17, 2020 14:38
@tamasvajk tamasvajk force-pushed the feature/csharp9-cil-init-prop branch from dcbcc88 to f3a0d1d Compare December 17, 2020 14:43
@tamasvajk tamasvajk marked this pull request as ready for review December 18, 2020 07:50
@tamasvajk tamasvajk requested a review from a team as a code owner December 18, 2020 07:50
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

Looks great to me. Some questions.


public override void WriteAssemblyPrefix(TextWriter trapFile) => Unmodified.WriteAssemblyPrefix(trapFile);

public override void WriteId(TextWriter trapFile, bool inContext)
Copy link
Contributor

Choose a reason for hiding this comment

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

I reckon this should never be called? So throw NotImplementedException would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. It would be a bug, if it was called.


public override string Name => Unmodified.Name + (IsRequired ? " modreq" : " modopt") + $"({Modifier.Name})";

public override void WriteAssemblyPrefix(TextWriter trapFile) => Unmodified.WriteAssemblyPrefix(trapFile);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this ever be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, changed it to an exception throwing.

@tamasvajk
Copy link
Contributor Author

@hvitved I found some perf issue in the differences job. The below shows up in the roslyn snapshot1 log, but not in snapshot0:

ClassDoesNotImplementEquals.ql-11:System::getInvokedIEquatableEqualsMethod#bbf#shared ............. 20.5s

I also found the below line with a huge number of rows:

Created relation System::getInvokedIEquatableEqualsMethod#bbf#shared/3@a7bede with 62679616 rows.

Can we have a look together? I'don't know how to move forward with this issue.

@hvitved
Copy link
Contributor

hvitved commented Jan 6, 2021

Oh no, we are running into the BDD issue again 😱

@tamasvajk
Copy link
Contributor Author

@hvitved
Copy link
Contributor

hvitved commented Jan 6, 2021

Oh no, we are running into the BDD issue again 😱

Apparently fixed by my latest change 🤷‍♂️

@tamasvajk tamasvajk merged commit 3b16d26 into github:main Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants