Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
みんな大好き Boo.Lang を SATSUGAI する方法
Search
Grabacr07
February 24, 2015
Technology
1
46k
みんな大好き Boo.Lang を SATSUGAI する方法
Visual Studio Tools for Unity 勉強会での LT 資料です。
VSTU の機能で、.sln / .csproj の生成処理にフックする方法について。
Grabacr07
February 24, 2015
Tweet
Share
More Decks by Grabacr07
See All by Grabacr07
Step up WPF
grabacr07
0
72k
デスクトップ アプリがこの先生きのこるには (2016)
grabacr07
2
88k
Windows 10 で遊ぶ Virtual Desktop
grabacr07
0
90k
Roslyn + KanColleViewer
grabacr07
0
1.1k
WPF 4.6
grabacr07
1
60k
UniRx とか Reactive Property とか
grabacr07
12
69k
Road to UI Library
grabacr07
0
260
WPF Digital Ink
grabacr07
0
38k
Modern WPF
grabacr07
0
34k
Other Decks in Technology
See All in Technology
NFV基盤のOpenStack更新 ~9世代バージョンアップへの挑戦~
vtj
0
360
Snowflakeの開発・運用コストをApache Icebergで効率化しよう!~機能と活用例のご紹介~
sagara
1
460
実は強い 非ViTな画像認識モデル
tattaka
3
1.3k
AWSではじめる Web APIテスト実践ガイド / A practical guide to testing Web APIs on AWS
yokawasa
8
710
遷移の高速化 ヤフートップの試行錯誤
narirou
6
1.2k
大規模アジャイルフレームワークから学ぶエンジニアマネジメントの本質
staka121
PRO
3
1.2k
OPENLOGI Company Profile for engineer
hr01
1
20k
技術スタックだけじゃない、業務ドメイン知識のオンボーディングも同じくらいの量が必要な話
niftycorp
PRO
0
110
Охота на косуль у древних
ashapiro
0
110
Pwned Labsのすゝめ
ken5scal
2
440
開発組織を進化させる!AWSで実践するチームトポロジー
iwamot
2
380
AIエージェント入門
minorun365
PRO
31
18k
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
A Tale of Four Properties
chriscoyier
158
23k
Git: the NoSQL Database
bkeepers
PRO
427
65k
Site-Speed That Sticks
csswizardry
4
410
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Thoughts on Productivity
jonyablonski
69
4.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
640
Typedesign – Prime Four
hannesfritz
40
2.5k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
133
33k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Transcript
Boo.Langを SATSUGAI する方法 2015/02/24 VSTU 勉強会 Manato KAMEYA (@Grabacr07) みんな大好き
Self Introduction Work 亀谷学人 - 株式会社グラニ C# + Unity でソーシャルゲーム開発
Private Microsoft MVP for .NET (Visual C#) Room metro Tokyo staff (Windows クライアント開発 勉強会) Twitter: @Grabacr07 Facebook: manao.kameya Blog: http://grabacr.net/ 最先端の C# をフルに活用 CTO: @neuecc (UniRx 開発者)
C# Everywhere Windows Desktop WinForms, WPF Windows 8 Windows Universal
apps Mac application Xamarin.Mac Web application ASP .NET MVC, ASP .NET Web API Game Unity, Playstation Mobile SDK Mobile (iOS, Android, WP) MonoTouch, Mono for Android Embedded, IoT .NET Framework Embedded Cloud Windows Azure, AWS
Boo.Lang の襲来 Visual Studio の補完機能 電球アイコンをクリック (もしくは Ctrl + .
(dot) でも出るよ!) 例: using System.Linq; が必要、なので書いてくれる
Boo.Lang の襲来 Visual Studio の補完機能 “List” と入力して補完すると…?
Boo.Lang の襲来 Visual Studio の補完機能 “List” と入力して補完すると…? 本当に必要なのは System.Collections.Generic の方
Boo.Lang が真っ先に出てくる ので、Ctrl + . (dot) -> Enter と高速で 入力すると Boo.Lang.List になってしまう
Visual Studio Tools for Unity に対する不満 Boo.Lang.dll への参照 ぶっちゃけ必要ない! が、VSTU
が自動的に追加 (Visual Studio で削除してもムダ) VSTU が生成した .sln or .csproj に不満がある なら加工しましょう!
Project File Generation VSTU の生成処理をフックする SyntaxTree.VisualStudio.Unity.Bridge.dll VSTU をインポートすると自動的に参照 (Editor project)
デバッグ実行可能 もちろん、ブレークポイントで止められます!
Project File Generation ProjectFilesGenerator class ProjectFileGeneration - 生成された .csproj に対するフック
SolutionFileGeneration - 生成された .sln に対するフック ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) => { // 中略 // 煮るなり焼くなりお好きに return result; };
Project File Generation ProjectFilesGenerator class ProjectFileGeneration - 生成された .csproj に対するフック
SolutionFileGeneration - 生成された .sln に対するフック ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) => { // 中略 // 煮るなり焼くなりお好きに return result; }; 対象ファイル名 例: "UnityVS.SampleProject1.CSharp.Editor.csproj" 生成されたファイルの中身 .csproj の場合は XML がずらずらと… 好きに加工して、文字列で返す
Boo.Lang への参照を削除 LINQ to XML を使う 本題から外れるので特に解説はしません :) static string
KillBooLang(string filename, string content) { var document = XDocument.Parse(content); document.Root .Descendants() .Where(x => x.Name.LocalName == "Reference") .Where(x => (string)x.Attribute("Include") == "Boo.Lang") .Remove(); return document.Declaration + Environment.NewLine + document.Root; }
Boo.Lang への参照を削除 LINQ to XML を使う 本題から外れるので特に解説はしません :) static string
KillBooLang(string filename, string content) { var document = XDocument.Parse(content); document.Root .Descendants() .Where(x => x.Name.LocalName == "Reference") .Where(x => (string)x.Attribute("Include") == "Boo.Lang") .Remove(); return document.Declaration + Environment.NewLine + document.Root; } … <ItemGroup> <Reference Include="mscorlib" /> <Reference Include="System" /> <Reference Include="System.XML" /> <Reference Include="System.Core" /> <Reference Include="Boo.Lang" /> <Reference Include="UnityScript.Lang" /> <Reference Include="UnityEngine"> … 要は、この行を削除 すればいいのです
Notice イベントを購読しているように見える 特に公式サンプルが… http://unityvs.com/documentation/api/project-file-generation/ Project(Solution)FileGeneration はただのデリゲート (まあ文字列返してる時点で気付けという話ではあるけども) 例えば次の場合 ProjectFilesGenerator.ProjectFileGeneration +=
Hook1; ProjectFilesGenerator.ProjectFileGeneration += Hook2; ProjectFilesGenerator.ProjectFileGeneration += Hook3; ProjectFilesGenerator.ProjectFileGeneration += Hook4;
Notice イベントを購読しているように見える 特に公式サンプルが… http://unityvs.com/documentation/api/project-file-generation/ Project(Solution)FileGeneration はただのデリゲート (まあ文字列返してる時点で気付けという話ではあるけども) 例えば次の場合 ProjectFilesGenerator.ProjectFileGeneration +=
Hook1; ProjectFilesGenerator.ProjectFileGeneration += Hook2; ProjectFilesGenerator.ProjectFileGeneration += Hook3; ProjectFilesGenerator.ProjectFileGeneration += Hook4; 有効なのは最後の 1 回だけ それ以前の 3 回は、呼び出されはする ものの、結果は無視される
Conclusion Project File Generation VSTU による .csproj / .sln 生成処理はフックできる
LINQ to XML で XML を加工して返してあげよう 例として Boo.Lang への参照を削除してみた T4 Template (.tt file) を取り込んだり、#define 定義したり? 快適な C# + Visual Studio ライフを!