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

Add Clear to ILProcessor #662

Merged
merged 1 commit into from
May 21, 2020
Merged

Add Clear to ILProcessor #662

merged 1 commit into from
May 21, 2020

Conversation

MichalPetryka
Copy link
Contributor

Clear can be useful when you need to rewrite a method from scratch.

@jbevain jbevain merged commit c1a3c19 into jbevain:master May 21, 2020
@jbevain
Copy link
Owner

jbevain commented May 21, 2020

Thanks!

@ltrzesniewski
Copy link
Contributor

Hmmm.... If you want to rewrite a method from scratch, there's a whole lot of other stuff you need to remove. I'm doing the following in a project of mine:

method.Body.Instructions.Clear();
method.Body.Variables.Clear();
method.Body.ExceptionHandlers.Clear();

method.DebugInformation.SequencePoints.Clear();
method.DebugInformation.Scope = null;
method.DebugInformation.StateMachineKickOffMethod = null;

method.CustomDebugInformations.Clear();

On the other hand, the ILProcessor only deals with the instruction list today, so I suppose making it clear a bunch of other stuff would not be appropriate.

@jbevain
Copy link
Owner

jbevain commented May 21, 2020

@ltrzesniewski yeah I think that's a different subject. At that point you might be better off creating a new method body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants