Skip to content

Instantly share code, notes, and snippets.

@maritaria
Created December 11, 2016 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maritaria/1eac2fcd8ee697e39491f72b3b013ea3 to your computer and use it in GitHub Desktop.
Save maritaria/1eac2fcd8ee697e39491f72b3b013ea3 to your computer and use it in GitHub Desktop.
Reproduction code
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
namespace CompilerGeneratedEnhancement
{
// Token: 0x02000002 RID: 2
public partial class Class1
{
// Token: 0x06000005 RID: 5 RVA: 0x000020D4 File Offset: 0x000002D4
public void EditThisMethod()
{
Console.WriteLine("How to reproduce:");
Console.WriteLine("1. Click on 'Edit C#'");
Console.WriteLine("2. Click on 'Compile'");
Console.WriteLine("Things that are wrong:");
Console.WriteLine("1. Compiler generated lambda helper classes/methods should be removed");
Console.WriteLine("2. Compiler generated backing fields for properties should be removed");
Console.WriteLine("3. Compiler generated backing fields for events should be removed");
Console.WriteLine("4. ");
this.MyEvent += new EventHandler(this.Class1_MyEvent);
this.MyProperty = this;
}
}
}
//This file contains the code in *.g.cs used to define the remaining class stuff
namespace CompilerGeneratedEnhancement
{
// Token: 0x02000002 RID: 2
public partial class Class1
{
// Token: 0x17000001 RID: 1
public global::CompilerGeneratedEnhancement.Class1 MyProperty
{
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
[global::System.Runtime.CompilerServices.CompilerGenerated]
get
{
return default(global::CompilerGeneratedEnhancement.Class1);
}
// Token: 0x06000002 RID: 2 RVA: 0x00002058 File Offset: 0x00000258
[global::System.Runtime.CompilerServices.CompilerGenerated]
set
{
}
}
// Token: 0x14000001 RID: 1
public event global::System.EventHandler MyEvent
{
// Token: 0x06000003 RID: 3 RVA: 0x00002064 File Offset: 0x00000264
[global::System.Runtime.CompilerServices.CompilerGenerated]
add
{
}
// Token: 0x06000004 RID: 4 RVA: 0x0000209C File Offset: 0x0000029C
[global::System.Runtime.CompilerServices.CompilerGenerated]
remove
{
}
}
public // Token: 0x06000006 RID: 6 RVA: 0x00002155 File Offset: 0x00000355
void Class1_MyEvent(object sender, global::System.EventArgs e)
{
}
// Token: 0x06000007 RID: 7 RVA: 0x0000215D File Offset: 0x0000035D
public void MethodWithLambda()
{
}
// Token: 0x06000008 RID: 8 RVA: 0x0000218B File Offset: 0x0000038B
public global::System.Collections.Generic.IEnumerable<string> YieldReturnTest()
{
return default(global::System.Collections.Generic.IEnumerable<string>);
}
// Token: 0x06000009 RID: 9 RVA: 0x0000219B File Offset: 0x0000039B
public Class1()
{
}
public // Token: 0x04000001 RID: 1
global::System.Collections.Generic.List<string> _yieldReturnTestStorage;
// Token: 0x04000002 RID: 2
[global::System.Runtime.CompilerServices.CompilerGenerated]
public global::CompilerGeneratedEnhancement.Class1 <MyProperty>k__BackingField;
// Token: 0x04000003 RID: 3
[global::System.Runtime.CompilerServices.CompilerGenerated]
public global::System.EventHandler MyEvent;
// Token: 0x02000004 RID: 4
[global::System.Runtime.CompilerServices.CompilerGenerated]
public sealed class <YieldReturnTest>d__11 : global::System.Collections.Generic.IEnumerable<string>, global::System.Collections.IEnumerable, global::System.Collections.Generic.IEnumerator<string>, global::System.IDisposable, global::System.Collections.IEnumerator
{
// Token: 0x0600000D RID: 13 RVA: 0x000021F1 File Offset: 0x000003F1
[global::System.Diagnostics.DebuggerHidden]
public <YieldReturnTest>d__11(int <>1__state)
{
}
// Token: 0x0600000E RID: 14 RVA: 0x0000220C File Offset: 0x0000040C
[global::System.Diagnostics.DebuggerHidden]
void global::System.IDisposable.Dispose()
{
}
// Token: 0x0600000F RID: 15 RVA: 0x0000224C File Offset: 0x0000044C
bool global::System.Collections.IEnumerator.MoveNext()
{
return default(bool);
}
public // Token: 0x06000010 RID: 16 RVA: 0x00002318 File Offset: 0x00000518
void <>m__Finally1()
{
}
// Token: 0x17000002 RID: 2
string global::System.Collections.Generic.IEnumerator<string>.Current
{
// Token: 0x06000011 RID: 17 RVA: 0x00002333 File Offset: 0x00000533
[global::System.Diagnostics.DebuggerHidden]
get
{
return default(string);
}
}
// Token: 0x06000012 RID: 18 RVA: 0x0000233B File Offset: 0x0000053B
[global::System.Diagnostics.DebuggerHidden]
void global::System.Collections.IEnumerator.Reset()
{
}
// Token: 0x17000003 RID: 3
object global::System.Collections.IEnumerator.Current
{
// Token: 0x06000013 RID: 19 RVA: 0x00002333 File Offset: 0x00000533
[global::System.Diagnostics.DebuggerHidden]
get
{
return default(object);
}
}
// Token: 0x06000014 RID: 20 RVA: 0x00002344 File Offset: 0x00000544
[global::System.Diagnostics.DebuggerHidden]
global::System.Collections.Generic.IEnumerator<string> global::System.Collections.Generic.IEnumerable<string>.GetEnumerator()
{
return default(global::System.Collections.Generic.IEnumerator<string>);
}
// Token: 0x06000015 RID: 21 RVA: 0x00002387 File Offset: 0x00000587
[global::System.Diagnostics.DebuggerHidden]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
return default(global::System.Collections.IEnumerator);
}
public // Token: 0x04000006 RID: 6
int <>1__state;
public // Token: 0x04000007 RID: 7
string <>2__current;
public // Token: 0x04000008 RID: 8
int <>l__initialThreadId;
// Token: 0x04000009 RID: 9
public global::CompilerGeneratedEnhancement.Class1 <>4__this;
public // Token: 0x0400000A RID: 10
global::System.Collections.Generic.List<string>.Enumerator <>s__1;
public // Token: 0x0400000B RID: 11
string <s>5__2;
}
}
}
using System;
using System.Collections.Generic;
namespace CompilerGeneratedEnhancement
{
public class Class1
{
private List<string> _yieldReturnTestStorage = new List<string> { "1", "2", "3" };
public Class1 MyProperty { get; set; }
public event EventHandler MyEvent;
public void EditThisMethod()
{
Console.WriteLine("How to reproduce:");
Console.WriteLine("1. Click on 'Edit C#'");
Console.WriteLine("2. Click on 'Compile'");
Console.WriteLine("Things that are wrong:");
Console.WriteLine("1. Compiler generated lambda helper classes/methods should be removed");
Console.WriteLine("2. Compiler generated backing fields for properties should be removed");
Console.WriteLine("3. Compiler generated backing fields for events should be removed");
MyEvent += Class1_MyEvent;
MyProperty = this;
}
private void Class1_MyEvent(object sender, EventArgs e)
{
throw new NotImplementedException();
}
public void MethodWithLambda()
{
_yieldReturnTestStorage.ForEach(s => Console.WriteLine(s));
}
public IEnumerable<string> YieldReturnTest()
{
foreach (string s in _yieldReturnTestStorage)
{
yield return s;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment