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
SourceGeneratorのススメ
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
tkym
January 24, 2026
Programming
1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SourceGeneratorのススメ
tkym
January 24, 2026
More Decks by tkym
See All by tkym
すこし踏み込む CancellationToken
htkym
2
680
AIの中の人になってみる
htkym
0
180
今さら聞けない .NET CLI
htkym
0
240
GitHubCopilotCLIのスラッシュコマンドを自作してみる
htkym
0
160
今さら聞けないCancellationToken
htkym
0
310
GitHub Copilot CLIのいいところ
htkym
2
1.5k
GitHubCopilotCLIをはじめよう.pdf
htkym
0
420
RoslynAnalyzerをつかってみよう
htkym
0
1.3k
SourceGeneratorのマーカー属性問題について
htkym
0
300
Other Decks in Programming
See All in Programming
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
470
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
160
一人だけ、Kiroが静止する日
hideg
0
120
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
250
アクセシビリティから考える情報設計
high_g_engineer
0
380
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
250
JRuby: Past, Present, and Future
headius
0
170
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.1k
AHC070解法紹介
eijirou
0
130
FreeBSDでZabbixを動かす
kenkino
0
310
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
220
Webの地図
yosuke_furukawa
PRO
6
4.7k
Featured
See All Featured
Visualization
eitanlees
152
17k
Color Theory Basics | Prateek | Gurzu
gurzu
1
470
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
850
The agentic SEO stack - context over prompts
schlessera
0
940
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
470
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
340
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Transcript
Source Generatorのススメ FutureOne株式会社 高山博司
高山博司 ・ FutureOne株式会社 ・ C#/.NET/Blazor tkym @h_tkymx
Source Generator
メタプログラミング ・ 他のコードを生成、変更、または分析できるコードを記述すること ・ 下記のものは ”実行時”に機能する。 リフレクション プログラムの実行中に、型 の情報を取得したり、それを 利用して動的にインスタンス
を作ったりする. スクリプティング 属性 (Attributes) コンパイラやフレームワーク に対して「これはこういう扱 いをしてね」という追加情報 を伝える コンパイル時には決まってい ないメソッドやプロパティに 対して、実行時にアクセスす る.(dynamic 型など). Roslyn Scripting APIを使っ て、文字列としてのC#コード を実行時にコンパイル・実行 することも可能. 式木(Expression Tree) コード(処理ロジック)を、コ ンパイル後の命令ではなく 『データ構造(ツリー状)』とし て扱う
C# Source Generator .NET 5 で導入されたコンパイル時のメタプログラミングツール なにがいいの? ・ 開発中に実行 ・
実行時のパフォーマンスが向上 ・ 新しいC#ソースファイルを生成し,自動的に追加 ・ リフレクションを排除 ・ AOTコンパイルとツリーシェイキングを可能に
AOT: Ahead of Time Compilation (事前コンパイル) 実行時ではなくビルド時に機械語へ変換する技術 ・ パフォーマンス向上 ・
起動時間の短縮 ・ ツリーシェイキングによるデプロイサイズの縮小 ・ 実行時の評価やリフレクションが不要
ソースジェネレーター VS. 生成AI
LoggerMeessage - .NET 6
GeneratedRegex - .NET 7 (.NET 9でプロパティも可能に)
System.Text.Json - .NET 8
Blazor Form Validation - .NET 10
Source Generatorの設計原則 ・ 「追加」のみで「変更」はしない 既存のC#コードを書き換えることはできない コンパイルプロセスに参加し、新しいC#ソースコードを追加する役割 ・ パイプラインによる高速化 ビルド速度を落とさないよう、必要なデータだけを抽出・キャッシュする 入力(ソースやファイル)から必要な情報だけを取り出し、変更があった場合のみコード再生成
・ 完全な独立性 順序不同: ジェネレーター同士の実行順序は決まっていない 相互不干渉: 他のジェネレーターが作ったコードは見えないし、触れない どのジェネレーターも「ユーザーが書いたコード(と外部ファイル)」だけを入力とする ・副作用のない純粋な処理 同じ入力なら常に同じ出力を返す。 診断(エラーや警告)も出力可能だが、ビルドプロセスを汚染しないように設計する
Source Generatorの実装 .NET 5 / C# 9 .NET 6 /
C# 10
C#/VBのコンパイラのオープンソース実装 dotnet/roslyn: The Roslyn .NET compiler provides C# and Visual
Basic languages with rich code analysis APIs. Roslynとは?
Compiler as a Service C# コンパイラ IL
Compiler as a Service C# コンパイラ IL Syntax Tree 構文木
Demo
まとめ Source Generator ・ 反復作業の削減 ・ リフレクションの排除 ・ AOTが可能に ・
https://github.com/dotnet/roslyn/blob/main/docs/features/incremental- generators.cookbook.md