Skip to content

Instantly share code, notes, and snippets.

@SLaks
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SLaks/9202893 to your computer and use it in GitHub Desktop.
Save SLaks/9202893 to your computer and use it in GitHub Desktop.
Run this code as 32 bit and 64 bit, and explain why it crashes on 32-bit
using System;
using System.ComponentModel;
using System.Linq;
class Program {
static void Main(string[] args) {
Console.WriteLine("Attributes: " + typeof(Program)
.GetMembers()
.SelectMany(m => m.GetCustomAttributes(true))
.Count()
);
}
[LogEvents(typeof(Program))]
public event EventHandler ꂢꂢ;
public event EventHandler ꂢꂢꂢꂢ;
public class LogEventsAttribute : Attribute {
public LogEventsAttribute(Type type) {
Console.WriteLine(String.Join(", ",
TypeDescriptor.GetEvents(type)
.Cast<EventDescriptor>()
.Distinct()
));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment