-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
C#: Extract init only accessors from CIL #4821
Conversation
1050ebf to
50343da
Compare
50343da to
dcbcc88
Compare
dcbcc88 to
f3a0d1d
Compare
There was a problem hiding this 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.
csharp/extractor/Semmle.Extraction.CIL/Entities/ModifiedType.cs
Outdated
Show resolved
Hide resolved
|
|
||
| public override void WriteAssemblyPrefix(TextWriter trapFile) => Unmodified.WriteAssemblyPrefix(trapFile); | ||
|
|
||
| public override void WriteId(TextWriter trapFile, bool inContext) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
@hvitved I found some perf issue in the differences job. The below shows up in the roslyn snapshot1 log, but not in snapshot0: I also found the below line with a huge number of rows: Can we have a look together? I'don't know how to move forward with this issue. |
|
Oh no, we are running into the BDD issue again 😱 |
Apparently fixed by my latest change 🤷♂️ |
initaccessors are normalsetaccessors in IL, except that there's amodreqapplied to them. To extract thismodreqormodoptthis PR introduces aModifiedType, which references the unmodified type, the modifier, and the isRequired flag. These types are not written to the trapfiles, which means that when aModifiedTypewould 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: