Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove methods from type

See original GitHub issue

Hello all!

I need a help again 😃 How to remove methods from a type? I’m trying to delete them like this (just example):

if (type.HasMethods) { for (int i = 0; i < type.Methods.Count; i++) { MethodDef method = type.Methods[i]; type.Methods.Remove(method); } } I see in debugger that method is removed from type.Methods list, but after saving assembly all methods are in the type.

Any ideas? Thanks in advance!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

0xd4dcommented, Jul 8, 2017

You don’t even need a loop if you’re removing every method, just call type.Methods.Clear().

Mefist0commented, Jul 8, 2017

Fu***ing .NET! I had to iterate my collection backwards. Oh, God!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type transformations in TypeScript: Removing functions from ...
In today's post, we are going the create a utility class for removing functions from a type. The technique can be used for...
Read more >
How to omit methods from a class type
You can remove functions from a type, but this will unfortunately remove fields that are functions as well: type OmitFunctions<T> = { [P...
Read more >
Type to remove methods from interface in Typescript
Type to remove methods from interface in Typescript - remove-methods-from-interface.ts.
Read more >
Documentation - Utility Types
Constructs a type by picking all properties from Type and then removing Keys (string literal or union of string literals). The opposite of...
Read more >
Update `.lean` type to automatically remove methods from ...
the problem is when using something like a class (especially in typegoose) where there are properties and methods on the same type, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found