So I ran a C# university program through de4dot and then reflector to decompile it and the following error appeared when I ran it in VS.
[assembly: System.Runtime.CompilerServices.Extension]
Error CS1112 Do not use 'System.Runtime.CompilerServices.ExtensionAttribute'. Use the 'this' keyword instead. Client C:\Users\user\Desktop\333\as2\decom\AssemblyInfo.cs 15 Active
I tried replacing the code with this and this() among other things but that just causes other problems. Can someone explain what I am to replace with 'this'? I feel like I am missing something obvious here.
You're meant to add the this
modifier to the method:
public static class FooExtensions
{
public static void DoSomething(this Foo foo)
{
...
}
}
That makes it an extension method.
In general thought, I wouldn't try to use a decompiler to "round trip" code - decompilers can be useful to see what the compiler has actually done, but there are various situations where the result won't be compilable.
See more on this question at Stackoverflow