そのレガシーな中でも最も近代的なプラットフォームと言えばやはりWPFで、WPFでアプリケーションを作るのならばやはりLivetは欠かせません。
Livet - ProjectHome
しかし、LivetはVS2015対応としてリリースされたver.1.3を最後に更新されておりません。
作者自身もVS2015対応版がLivet 1.xの最終リリースとする旨の発言をしており、今後はLivet2を開発すると言っています。
ugaya40/Livet2 - GitHub
しかし、現時点でLivet2のLastest commitは2015年8月。Livetの最大の武器ともいえるプロジェクトテンプレート付きのインストーラはおろか、正式リリースさえされていない状態です。このような状況ではVS2017対応は絶望的です。
そうすると、何とかして自力でLivetをVS2017にインストールしなければなりません。
さて、VS2013とVS2015がリリースされた直後も、自力でLivetのプロジェクトテンプレートを組み込んでいた漢たちはいました。
最強のWPF MVVMインフラ「Livet」をVS2013で使う
最強のWPF MVVMインフラ「Livet」をVS2015で使う
Livet自体もこの時からほとんど進んでいませんし、こちらのページで紹介されているバッチファイルをちょっと改造すればいけるでしょう。
の前に、コードスニペットを改良しておきます。
本来、その改良はVS2015対応でやるべきでした。
VS2015と同時にリリースされたC#6でnameof演算子が導入されています。この、INotifyPropertyChangedインターフェースの実装に使ってくださいと言わんばかりの機能を通知プロパティのスニペットに使わない理由は無いでしょう。
ちなみに、.NET4.5からはCallerMemberName属性を使うことで自動的に呼び出し元のプロパティ名を引数としてメソッドに引き渡す機能があるので、通知プロパティの実装にそれを使う人も多いようです(Livetももちろんそれに対応しています)。しかし、「書いてもいないものが勝手に生成される」という気持ち悪さから私はこの言語機能を使いたくないので、nameofを使ったコードを書くことにしています。
というわけで、GitHubからダウンロードしたLivet-master\Installer\Files\Snippets内のLivetProperty_NET45_CSharp.snippetは削除して、LivetProperty_NET40_CSharp.snippetをnameof演算子に書き換えておきましょう(VBも必要があればやっておくといいと思います)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <? xml version = "1.0" encoding = "utf-8" ?> < CodeSnippet Format = "1.0.0" > < Header > < Title >Livet プロパティ</ Title > < Shortcut >lprop</ Shortcut > < Author >Livet Project</ Author > < Description >プロパティを作成します</ Description > < SnippetTypes > < SnippetType >Expansion</ SnippetType > </ SnippetTypes > </ Header > < Snippet > < Imports > < Import > < Namespace >Livet</ Namespace > </ Import > </ Imports > < Declarations > < Literal > < ID >type</ ID > < ToolTip >プロパティの型</ ToolTip > < Default >string</ Default > </ Literal > < Literal > < ID >name</ ID > < ToolTip >プロパティ名</ ToolTip > < Default >MyProperty</ Default > </ Literal > </ Declarations > < Code Language = "csharp" > <![CDATA[ #region $name$変更通知プロパティ private $type$ _$name$; public $type$ $name$ { get { return _$name$; } set { $end$ if(_$name$ == value) return; _$name$ = value; RaisePropertyChanged(nameof($name$)); } } #endregion ]]> </ Code > </ Snippet > </ CodeSnippet > </ CodeSnippets > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | @ echo off cd %~d0% ~p0 @ echo on echo copy snippets xcopy /I /Y .\Files\Snippets\*_CSharp.* "%UserProfile%\Documents\Visual Studio 2017\Code Snippets\Visual C#\My Code Snippets\Livet" xcopy /I /Y .\Files\Snippets\*_VB.* "%UserProfile%\Documents\Visual Studio 2017\Code Snippets\Visual Basic\My Code Snippets\Livet" echo project templates call :copy_project_template_csharp Livet_WPF4.0_CSharp call :copy_project_template_csharp Livet_WPF4.5_CSharp call :copy_project_template_vb Livet_WPF4.0_VB call :copy_project_template_vb Livet_WPF4.5_VB echo item templates call :copy_item_template_csharp LivetInteractionMessageAction_CSharp call :copy_item_template_csharp LivetMessage_CSharp call :copy_item_template_csharp LivetModel_CSharp call :copy_item_template_csharp LivetViewModel_CSharp call :copy_item_template_csharp LivetWindow_CSharp call :copy_item_template_vb LivetInteractionMessageAction_VB call :copy_item_template_vb LivetMessage_VB call :copy_item_template_vb LivetModel_VB call :copy_item_template_vb LivetViewModel_VB call :copy_item_template_vb LivetWindow_VB echo simple install completed!!! pause :copy_pro ject_template_csharp xcopy /I /E /Y .\Files\Templates\ %1 "%UserProfile%\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#\%1" exit /b :copy_pro ject_template_vb xcopy /I /E /Y .\Files\Templates\ %1 "%UserProfile%\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual Basic\%1" exit /b :copy_ite m_template_csharp xcopy /I /E /Y .\Files\Templates\ %1 "%UserProfile%\Documents\Visual Studio 2017\Templates\ItemTemplates\Visual C#\%1" exit /b :copy_ite m_template_vb xcopy /I /E /Y .\Files\Templates\ %1 "%UserProfile%\Documents\Visual Studio 2017\Templates\ItemTemplates\Visual Basic\%1" exit /b |
Prism使うしかないのかなと思ってました、ありがとうございます!
返信削除Livet2は諦めるしかないのですかねー
Livetはもう死んだと諦めた方がいいんでしょうね。
返信削除開発者本人ですらなんのアクションも起こさないし、Issueも出ない、プルリクもない、フォークすらされない
こんなフレームワークは早々に切るべきと私は結論付けしました。
そうですよね、残念ですけど自分も諦めます。
削除Livet2が息を吹き返したようです。
返信削除https://blog.okazuki.jp/entry/2018/10/25/105244
2017年8月18日 11:08 にコメントした匿名です。
削除自分もたった今Livet2をみつけて急いでここに来ました。
また使ってみたいです。