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
tkym
February 28, 2026
Programming
310
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
SourceGeneratorのマーカー属性問題について
tkym
February 28, 2026
More Decks by tkym
See All by tkym
GitHub Agentic Workflows を触ってみる
htkym
2
950
すこし踏み込む CancellationToken
htkym
2
1.7k
AIの中の人になってみる
htkym
0
220
今さら聞けない .NET CLI
htkym
0
270
GitHubCopilotCLIのスラッシュコマンドを自作してみる
htkym
0
170
今さら聞けないCancellationToken
htkym
0
330
GitHub Copilot CLIのいいところ
htkym
2
1.5k
GitHubCopilotCLIをはじめよう.pdf
htkym
0
430
RoslynAnalyzerをつかってみよう
htkym
0
1.3k
Other Decks in Programming
See All in Programming
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
360
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
140
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
220
JRuby: Past, Present, and Future
headius
0
230
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
350
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
320
contenteditable と日本語入力に向き合う
colorful12
0
180
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
570
Agents on Rails - Rails at Scale 2026
irinanazarova
0
530
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
540
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
370
カツオ、ご期待ください
suneo3476
0
160
Featured
See All Featured
Paper Plane (Part 1)
katiecoart
PRO
2
11k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
580
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
420
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
530
A Soul's Torment
seathinner
8
3.7k
It's Worth the Effort
3n
188
29k
Leo the Paperboy
mayatellez
10
2.4k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
610
Joys of Absence: A Defence of Solitary Play
codingconduct
1
540
Prompt Engineering for Job Search
mfonobong
0
500
Transcript
Source Generatorの マーカー属性問題について 2026/02/28 .NETラボ勉強会2月
高山博司 ・ FutureOne株式会社 ・ C#/.NET/Blazor tkym @h_tkymx
Source Generator
C# Source Generator コンパイル時のメタプログラミングツール ・ 新しいC#ソースファイルを生成し,自動的に追加 ・ 開発中に実行 ・ 実行時のパフォーマンスが向上
・ リフレクションを排除 ・ AOTコンパイルとツリーシェイキングを可能に 前回の内容 https://zenn.dev/poipoionigiri/articles/57f1c33a7f5baa
どのクラス、メソッド、あるいはプロパティに対してコードを生成すべきか Syntactic Filtering: 非常に高速。テキスト情報やトークンの種類だけで判断する。 Semantic Analysis: 非常に高コスト。型解決、継承関係の確認、他アセンブリのメタデータ参照を含む。
マーカー属性 ForAttributeWithMetadataName
マーカー属性 AllInterfaces はやめましょう... ・ 推移的な依存関係 ・ アセンブリ境界の越境 ・ 増分ビルドの破壊
Blazor Form Validation - .NET 10
Marker Attribute Problem
マーカー属性の定義場所 どこにマーカー属性を定義すればよい? マーカー属性もSource Generatorでつくる?
CS0246(型または名前空間が見つかりません) × Attributeを出すだけのGeneratorを作る × 出力コードの中にAttributeの定義も混ぜ込む
Attribute用のライブラリを作る △ 2つも依存関係もつの・・・? スタンドアロンなSource Generatorがいい !
RegisterPostInitializationOutput ◎ ジェネレーターの起動時にフックして,固定のコードを差し込める. 「マーカー属性を追加してね」と言わんばかりのメソッド
CS0436 : 型の競合 複数プロジェクトにSource Generatorを入れていて, それらが依存関係にある場合に, [CS0436 : 型の競合 ]
警告が出る. → internal class
internal...
CS0436 : 型の競合(InternalsVisibleTo編) [InternalsVisibleTo]: 指定されたアセンブリに対して、通常は internal アクセスレ ベルで保護されている型やメンバーへのアクセス権を付与する宣言的な属性
CS0436 : 型の競合 (InternalsVisibleTo編) × Source Generatorに属性クラスを直接含め、DLL 自体を通常の参照としても使う ・ Source
Generatorの依存がユーザーに流れてしまう. ・ バージョンの競合が起こる可能性 ・ analyzerとして使ってほしい
CS0436 : 型の競合 (InternalsVisibleTo編) Source Generator パッケージにAttribute DLLをパックする
CS0436 : 型の競合 (InternalsVisibleTo編) .NET 10 ・ 出力するアトリビュートに[Embedded]を付与 ・ ResisterPostInitializeationOutput時に
AddEmdeddedAttributeDefinitionを呼ぶ
まとめ Source Generator の Marker Attribute Problem ・ RegisterPostInitializationOutputで Source
Generatorで生成することを考える. → Attribute は internal class ・ 複数プロジェクトで使いたい場合は,依存関係に注意 → .NET 10 では,[Embedded]を使う → それ以前では,一工夫した方が使いやすいかも