SlideShare a Scribd company logo
1 of 31
Pokaż kotku,
co masz w środku
Czyli jak wygląda kod C# po przetworzeniu przez
kompilator
Who am I?
 Ryszard Skonieczka
 pl.carnifex@gmail.com
Agenda
 IL – what is it?
 How to get read compiled code and see IL?
 New command or just syntactic sugar?
 Usage in real life
 How to protect my code?
 Q & A
Agenda
 IL – what is it?
 How to get read compiled code and see IL?
 New command or just syntactic sugar?
 Usage in real life
 How to protect my code?
 Q & A
IL – what is it?
 Common Intermediate language
 Native code
 Assembler for .NET
Source: wikipedia.org
Agenda
 IL – what is it?
 How to get read compiled code and see IL?
 New command or just syntactic sugar?
 Usage in real life
 How to protect my code?
 Q & A
How to get read compiled
code and see IL?
 IL DASM
 Reflector
 DotPeek
 JustDecompile
Agenda
 IL – what is it?
 How to get read compiled code and see IL?
 New command or just syntactic sugar?
 Usage in real life
 How to protect my code?
 Q & A
New command or
just syntactic sugar?
 .NET vs C#
 Examples
Source: wikipedia.org
New command or
just syntactic sugar? Examples
 lock()
Syntactic sugar!
Examples
 lock()
Syntactic sugar!
Examples
 foreach
Syntactic sugar!
Examples
 Access to modified closure
Syntactic sugar!
Examples
 foreach (Arrays)
Syntactic sugar!
Examples
 for
Syntactic sugar!
Examples
 using()
Syntactic sugar!
Examples
 Lambda expressions
Syntactic sugar!
Examples
 Lambda expressions
Syntactic sugar!
Examples
 yield
Syntactic sugar!
Examples
 Auto-Implemented Properties
Syntactic sugar!
Examples
 Auto-Implemented Events
Syntactic sugar!
Examples
 C# 6.0 Features
Source: How C# 6.0 Simplifies, Clarifies and Condenses Your Code
Author: Mark Michaelis
Syntactic sugar!
Examples
 Collection Initialization
Agenda
 IL – what is it?
 How to get read compiled code and see IL?
 New command or just syntactic sugar?
 Usage in real life
 How to protect my code?
 Q & A
Usage in real life
 EventHandlerList
 Use C#6 goodies on XP
 Better locks
 ildasm, ilasm
 Emit
Usage in real life
Emit
Agenda
 IL – what is it?
 How to get read compiled code and see IL?
 New command or just syntactic sugar?
 Usage in real life
 How to protect my code?
 Q & A
How to protect my code?
 Obfuscation
 Dotfuscator
 ConfuserEx
Author: Martin Fowler
Agenda
 IL – what is it?
 How to get read compiled code and see IL?
 New command or just syntactic sugar?
 Usage in real life
 How to protect my code?
 Q & A
Q & A
 Any questions?
Thank you!
 pl.carnifex@gmail.com
 https://www.jetbrains.com/decompiler/
 http://yck1509.github.io/ConfuserEx/
 http://1drv.ms/1Xo9ql2

More Related Content

Similar to C# IL Intermediate Language Explained

CICON2010: Phil Sturgeon - Running an Open-Source CodeIgniter project
CICON2010: Phil Sturgeon - Running an Open-Source CodeIgniter projectCICON2010: Phil Sturgeon - Running an Open-Source CodeIgniter project
CICON2010: Phil Sturgeon - Running an Open-Source CodeIgniter projectCodeIgniter Conference
 
Running an Open-Source CodeIgniter project
Running an Open-Source CodeIgniter projectRunning an Open-Source CodeIgniter project
Running an Open-Source CodeIgniter projectPhil Sturgeon
 
OpenAPI at Scale
OpenAPI at ScaleOpenAPI at Scale
OpenAPI at ScaleNordic APIs
 
Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)DotNetMarche
 
Writing Rust Command Line Applications
Writing Rust Command Line ApplicationsWriting Rust Command Line Applications
Writing Rust Command Line ApplicationsAll Things Open
 
Unleashing the Power of Automated Refactoring with JDT
Unleashing the Power of Automated Refactoring with JDTUnleashing the Power of Automated Refactoring with JDT
Unleashing the Power of Automated Refactoring with JDTNaresh Jain
 
Mongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case StudyMongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case StudyMitch Pirtle
 
Know your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvmKnow your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvmPawel Szulc
 
DWX 2013 Nuremberg
DWX 2013 NurembergDWX 2013 Nuremberg
DWX 2013 NurembergMarcel Bruch
 
MongoDB World 2018: A Swift Introduction to Swift
MongoDB World 2018: A Swift Introduction to SwiftMongoDB World 2018: A Swift Introduction to Swift
MongoDB World 2018: A Swift Introduction to SwiftMongoDB
 
Notes (2012-06-08)
Notes (2012-06-08)Notes (2012-06-08)
Notes (2012-06-08)Chris Pitt
 
apidays LIVE New York - API Code First vs Design First by Phil Sturgeon
apidays LIVE New York - API Code First vs Design First by Phil Sturgeonapidays LIVE New York - API Code First vs Design First by Phil Sturgeon
apidays LIVE New York - API Code First vs Design First by Phil Sturgeonapidays
 
Functional IoT: Introduction
Functional IoT: IntroductionFunctional IoT: Introduction
Functional IoT: IntroductionKiwamu Okabe
 
MongoDB.local Dallas 2019: MongoDB and Spark
MongoDB.local Dallas 2019: MongoDB and SparkMongoDB.local Dallas 2019: MongoDB and Spark
MongoDB.local Dallas 2019: MongoDB and SparkMongoDB
 
How Optimizely Scaled its REST API with asyncio
How Optimizely Scaled its REST API with asyncio  How Optimizely Scaled its REST API with asyncio
How Optimizely Scaled its REST API with asyncio Optimizely
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2Hammad Rajjoub
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2Hammad Rajjoub
 

Similar to C# IL Intermediate Language Explained (20)

CLEAN WEB
CLEAN WEBCLEAN WEB
CLEAN WEB
 
From keyboard to production
From keyboard to productionFrom keyboard to production
From keyboard to production
 
CICON2010: Phil Sturgeon - Running an Open-Source CodeIgniter project
CICON2010: Phil Sturgeon - Running an Open-Source CodeIgniter projectCICON2010: Phil Sturgeon - Running an Open-Source CodeIgniter project
CICON2010: Phil Sturgeon - Running an Open-Source CodeIgniter project
 
Running an Open-Source CodeIgniter project
Running an Open-Source CodeIgniter projectRunning an Open-Source CodeIgniter project
Running an Open-Source CodeIgniter project
 
OpenAPI at Scale
OpenAPI at ScaleOpenAPI at Scale
OpenAPI at Scale
 
Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)
 
Writing Rust Command Line Applications
Writing Rust Command Line ApplicationsWriting Rust Command Line Applications
Writing Rust Command Line Applications
 
Unleashing the Power of Automated Refactoring with JDT
Unleashing the Power of Automated Refactoring with JDTUnleashing the Power of Automated Refactoring with JDT
Unleashing the Power of Automated Refactoring with JDT
 
Mongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case StudyMongodb and Totsy - E-commerce Case Study
Mongodb and Totsy - E-commerce Case Study
 
Know your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvmKnow your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvm
 
DWX 2013 Nuremberg
DWX 2013 NurembergDWX 2013 Nuremberg
DWX 2013 Nuremberg
 
MongoDB World 2018: A Swift Introduction to Swift
MongoDB World 2018: A Swift Introduction to SwiftMongoDB World 2018: A Swift Introduction to Swift
MongoDB World 2018: A Swift Introduction to Swift
 
Notes (2012-06-08)
Notes (2012-06-08)Notes (2012-06-08)
Notes (2012-06-08)
 
apidays LIVE New York - API Code First vs Design First by Phil Sturgeon
apidays LIVE New York - API Code First vs Design First by Phil Sturgeonapidays LIVE New York - API Code First vs Design First by Phil Sturgeon
apidays LIVE New York - API Code First vs Design First by Phil Sturgeon
 
Functional IoT: Introduction
Functional IoT: IntroductionFunctional IoT: Introduction
Functional IoT: Introduction
 
MongoDB and Spark
MongoDB and SparkMongoDB and Spark
MongoDB and Spark
 
MongoDB.local Dallas 2019: MongoDB and Spark
MongoDB.local Dallas 2019: MongoDB and SparkMongoDB.local Dallas 2019: MongoDB and Spark
MongoDB.local Dallas 2019: MongoDB and Spark
 
How Optimizely Scaled its REST API with asyncio
How Optimizely Scaled its REST API with asyncio  How Optimizely Scaled its REST API with asyncio
How Optimizely Scaled its REST API with asyncio
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

C# IL Intermediate Language Explained

Editor's Notes

  1. Krótkie info o sobie. Gdzie pracuje, jako kto, z jakimi aplikacjami mam do czynienia.
  2. Krótkie wytłumaczenie co to jest IL przez co jest używany. Dlaczego kompilacja do kodu pośredniego jest dobra (optymalizacja maszyny wirtualnej, bez konieczności przekompilowania programu) Krótki przykład fragmentu kodu. Kompilacja do kodu maszynowego/nartwnego. Ngen.exe (Native Image Generator) IL jest jak Assembler tylko że dla .NET
  3. Pokażę narzędzia dzięki którym można dostać się do ILa i narzędzia dzięki którym można zobaczyć kod w „programmer friendy way” – czyli kod w C#
  4. Ildasm – dostępny wszędzie, bo jest częścią .NETa, a dokładniej Framework SDK Reflector – ostatnia darmowa wersja to 6. Ma możliwość dekompilacji do różnych języków DotPeek – aplikacja gości od R# (JetBrains), w wersji 10 (w końcu) dodali możliwość pokazania ILa JustDecompile – aplikacja Telerik’a – w przeszłości miała duże problemy z dekompilacją kodu
  5. Różnica pomiędzy samym językiem (możliwościami IDE, kompilatora) a Frameworkiem (prawdziwymi poleceniami). Jeśli wiemy co jest częścią języka, a co frameworka, można pisać kod w VS15 a uruchamiać nawet na .NET2.0 
  6. Atrybut Synchronized. Nie używać! Bo robi lock’a na this To w rzeczywistości nie jest tłumaczone… ale taka ciekawostka jak co ten atrybut robi
  7. Lock jest zamieniany na konstrukcję z użyciem Monitor’a. Taki wygląd jest w C#5, wcześniej nie było „lockTaken”
  8. Foreach zostaje zamieniony na while’a, który przebiega się po enumeratorze. W C#4.0 konstrukcja wyglądała tak. W wersji 5.0 (chyli .NET4.5) zmienna „i” została wcielona do ciała while
  9. R# zgłasza błąd jeśli zastosujemy pokazany kod. Pytanie do publiczności: Kto może powiedzieć jaki będzie wynik? Co zostanie wyświetlone na konsoli?
  10. Pytanie: Który kod zadziała szybciej? Ten z foreach’em, czy for’em? Bo nie raz słyszałem różne opinie… Taki zabieg kompilator zastosuje TYLKO jeśli kolekcja jest tablicą, jeśli zastosujemy coś innego (nawet IList<>, które ma indeksera) to dostaniemy standardowy GetEnumerator() i MoveNext().
  11. For – także jest cukiereczkiem… zostaje zamieniony na odpowiednik while’a, który wygląda tak.
  12. Chyba jednym z najbardziej znanych cukiereczków jest using().
  13. Niektórzy mogli coś przypuszczać, że z lambdami jest „coś” nie tak, jak poleciał exception i w stackTrace dostaliśmy dziwne metody <>b_1. Jeśli w lambdzie używany jest field, to kompilator stworzy nam nową metodę w klasie i utworzy delegatę do tej metody
  14. Jeśli w lambdzie będziemy chcieli użyć zmiennych lokalnych z metody… kompilator utworzy nową klasę, doda pola, które odpowiadają użytym zmiennym, a następnie utworzy delegatę do metody z tej klasy.
  15. Jeszcze większa „magia” dzieje się jak zastosujemy konstrukcje z „yield”. Utworzona zostanie nowa klasa (Enumerator), a metodzie MoveNext() będziemy mieli sekwencję switch/case, odpowiadającą poszczególnym sekcją „yield return”
  16. Ok, wspominałem wcześniej że Using() jest najbardziej znanym syntactic sugar… Ale chyba to wszyscy znają i używają 
  17. Przy eventach także dzieje się coś „ekstra” po stronie kompilatora. Kod po lewej można określić jako Auto-Implemented Events. W rzeczywistości kompilator tworzy delegatę wskazanego typu, a do samego eventa dodaje accessory „add” i „remove”, które modyfikują tą delegatę. Jeśli w kodzie tej klasy odwołamy się do eventa, to w rzeczywistości będziemy odwoływać się do tego automatycznego delegata. Implementacja accessorów różna jest w zależności jakim kompilatorem zostało skompilowane. Od 4.0 używany jest Interlock do podmiany delegaty, wcześniej (3.0) był zwykły Delegate.Combine z lockiem na „this” – o zgrozo… Informacja że to jest „auto implemented” i zawsze tworzymy dodatkowe pole… dlatego w kontrolkach jest używany „EventHandlerList”
  18. Większość nowości to cukiereczki. String interpolation, to zwykły String.Format. nameOf w czasie kompilacji jest zamieniane na stringi. A deklaracja metod jako lambdy, jest zamieniana na zwykłe metody. W Microsoft Magazine, słowa „Marka Michaelisa” mówią same za siebie 
  19. W C# 6.0 dochodzi nowy collection initializer, czyli inicjalizacja po indekserze. Należy jednak pamiętać że różni się to od poprzedniej wersji. Add wyrzuci exception jeśli natrafi na tą samą wartość, przypisanie indekserem – nie!! Warto o tym pamiętać.
  20. Gdzie ta wiedza nam się może przydać?
  21. Już wspominałem wcześniej, optymalizacja eventów. Jak wiemy co należy do specyfikacji języka a co frameworka, można kompilować i używać aplikacji na XP Można bardziej zoptymalizować np. locki. Wiedząc że lock() to to samo co Monitor(), można zamienić w niektórych sytuacjach na SpinLock’a Modyfikacja exe. ildasm Program.exe /out=Program.il Zmiana w pliku .il ilasm Program.il /output=Prog2.exe
  22. Emit – umożliwia dynamiczne tworzenie kodu. Możemy dzięki temu stworzyć dowolną klasę/metodę „w locie”/w trakcie działania programu. Oczywiście później taką wygenerowaną klasę i assembly można zapisać na dysku jako plik dll. Działają tak mock’i, hibernate (tworzący obiekty proxy), etc.
  23. Ok, pokazałem, jak można zobaczyć każdy kod i go zdekompilować. Czy istnieje więc sposób aby zabezpieczyć swój kod przed wścibskimi?
  24. Najskuteczniejszą opcją jest pisanie nieczytelnego kodu, tak abyśmy tylko my go zrozumieli. Ale nie jest wyjście – cytat Martina. Więc kod źródłowy powinien być zawsze jak najbardziej zrozumiały dla wszystkich (nie tylko dla nasz i naszego zespołu). Obfuskacja może nastąpić przed kompilacją lub też po niej – w tym przypadku program operuje właśnie na IL. Dostępne są płatne wersję oferujące dużo. Można także użyć darmowych odpowiedników, które całkiem nieźle sobie radzą. Ostatecznie jak ktoś jest zdeterminowany, nic go nie powstrzyma i zawsze dostanie się do naszego kodu :P
  25. 1drv – znajdą się binarki ze wszystkich wersji .NET, przykładowa apka HelloWorld oraz ta prezentacja 