Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
.NET Day 2019 - Abusing the C# compiler by Fili...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
.NET Day
May 28, 2019
Technology
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
.NET Day 2019 - Abusing the C# compiler by Filip Wojcieszyn
.NET Day
May 28, 2019
More Decks by .NET Day
See All by .NET Day
.NET Day 2026 What I learned from modernizing a microservices architecture
dotnetday
0
38
.NET Day 2026 The impact and relevance of code reviews on software quality
dotnetday
0
45
.NET Day 2026 From Co-Pilot to Co-Worker: Mastering GitHub Copilot Agent Mode
dotnetday
0
49
.NET Day 2026 Are you sure your access tokens are really secure?
dotnetday
0
35
.NET Day 2026 The death of Passwords, Implementing Passkeys in .NET 10
dotnetday
0
48
.NET Day 2026 How Banks Protect Their Applications with FAPI
dotnetday
0
30
.NET Day 2026 AI Your Way: MCPs vs Skills vs SubAgents 🤖🚀
dotnetday
0
43
.NET Day 2026 The Past, Present and Future of Programming Languages
dotnetday
0
52
.NET Day 2026 Mis-Estimating – why estimating effort does not work
dotnetday
0
46
Other Decks in Technology
See All in Technology
SDDの運用にめげずに向き合った話
sansantech
PRO
1
130
オンラインゲームのシステム全体像 - コロプラ 2026年度 新卒研修
colopl
0
840
生成AIと進める探索的データ分析(2026.10.03 第122回Tokyo.R勉強会)
tatamiya
2
1.4k
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
310
1万名の社員が使う認証基盤で どう信頼性を担保するか?
kairim0
0
210
プロダクト価値を、 チームが使える判断軸に変える
vivion
0
130
AIに攻撃される前に、AIに攻撃させる
tsuchikazu
0
150
全人類(ほぼ)AWS Organizations の上でAWSを利用している、その世界を知る話
htan
0
120
生成AIで高い生産性を求められて、 悩み、乗り越えた話
mot_techtalk
2
130
メルペイ 会計システム概要と歴史
mewuto
0
190
形式手法を使って仕様をコーディングしよう
mikanichinose
0
180
Meet AgentCore Identity Consent Portal
hironobuiga
3
190
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
570
How GitHub (no longer) Works
holman
316
150k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
550
Deep Space Network (abreviated)
tonyrice
0
360
The World Runs on Bad Software
bkeepers
PRO
72
12k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Between Models and Reality
mayunak
4
480
Into the Great Unknown - MozCon
thekraken
41
2.8k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
450
GitHub's CSS Performance
jonrohan
1033
470k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Transcript
Abusing the C# Abusing the C# Compiler Compiler for fun
and no pro t for fun and no pro t
Filip W Filip W a random guy from the internet
• • strathweb.com @ lip_woj github.com/ lipw
None
What will we What will we learn? learn?
Nothing.
We will however see, that it doesn't take a lot
to violate the rules of C#.
C# Compiler C# Compiler
None
“ Compiler is the guardian of the integrity of the
language.
C# 6 Draft Spec Reading C# 6 Draft Spec Reading
High level C# building blocks High level C# building blocks
C# Languague Speci cation ECMA Standard, ~500 pages ⚙ Roslyn Compiler compiles C# code to Common Intermediate Language Tooling powered by the C# Compiler CLR / CoreCLR compiles CIL to machine code
Can you trust the Can you trust the compiler? compiler?
- Mads Torgersen, C# Lead Designer “ Customers will depend
on the new compiler behaving exactly the same way as the old one. Writing a new compiler for C# means trying to match the old compiler bug-for-bug.
Invalid C#, compiler error Invalid C#, compiler error static class
Foo {} class Bar { // error CS0722: 'Foo': static types cannot be used as return types Foo GetFoo() => null; }
Invalid C#, no compiler error Invalid C#, no compiler error
static class Foo {} interface IBar { // compiles fine Foo GetFoo(); }
Can the compiler produce a program that won't work? Yes
Let's assume that the code is 100% error free. Still
yes
Language Spec Compiler Runtime
Can the runtime allow you to violate the C# language
speci cation? Yes
Language Spec Compiler Runtime
- Eric Lippert “ A common technique (...) is to
have the compiler “lower” from high-level language features to low-level language features in the same language.
C# using block C# using block using(new C()) { //
do stuff }
Emitted IL Emitted IL IL_0000: nop IL_0001: newobj instance void
C::.ctor() IL_0006: stloc.0 .try { IL_0007: nop IL_0008: nop IL_0009: leave.s IL_0016 } // end .try finally { // sequence point: hidden IL_000b: ldloc.0 IL_000c: brfalse.s IL_0015 IL_000e: ldloc.0 IL_000f: callvirt instance void [mscorlib]System.IDisposable::Dispose() IL_0014: nop // sequence point: hidden IL_0015: endfinally } // end handler
“ This method terminates a process without running any active
try/ nally blocks or nalizers. - Environment.FailFast(...)
So far we have managed to So far we have
managed to ✅ Create an instance without calling a constructor ✅ Bypass a ' nally' clause ✅ Create an instance of an open generic
Can the compiler produce code that doesn’t behave as expected?
Yes
Language Spec Compiler Runtime
How badly can you abuse the language and the compiler?
Very badly
Language Spec Compiler Runtime
Thank you Thank you See you next year! lipw.github.io/dotnetday-zurich-2019 github.com/
lipw/2019-switzerland- netday-demos