Skip to content

Instantly share code, notes, and snippets.

View yfakariya's full-sized avatar
🎯
Focusing

Yusuke Fujiwara yfakariya

🎯
Focusing
View GitHub Profile
@yfakariya
yfakariya / IsNull.cs
Created October 28, 2015 14:24
IsNull revised
using System;
static class Program
{
static void Main()
{
Test( "a" );
Test( 1 );
Test<int?>( 1 );
}
@yfakariya
yfakariya / ProtoBufCompatIdea.cs
Created August 5, 2012 13:40
An idea to resolve incompatibility of DataMemberAttribute.Order's lower bound between msgpack and protobuf.
// Initialize SerializationContext, which can be singleton.
var context = new SerializationContext();
// Set compatibility option, which set array lower bounds to 1 instead of 0.
context.CompatibilityOptions.OneDataMemberLowerBound = true;
// Following is as is...
var serializer = MessagePackSerializer.Create<Foo>( context );
using( var stream = new MemoryStream() )
{
@yfakariya
yfakariya / gist:fb6d5c66fa4d8a82346b
Last active September 4, 2015 11:27
Spec draft for embedding type information

Purpose 目的

Make .NET to .NET serialization more easily by embedding type information. Interoperability should be considered as possible. 型情報を埋め込むことで、.NET どうしのシリアライズをもっと楽にする。相互運用性は可能な限り考慮されるべき。

Usecase ユースケース

  1. Serialize polimorphic collection (issue #58) ポリモーフィックなコレクションをシリアライズする
  2. Serialize 'rich' domain model which has own data and logic (issue #47)
@yfakariya
yfakariya / gist:64cbd15868f78604ef86
Created January 11, 2015 13:33
Visual Studio のプロジェクト追加ダイアログの既定の言語を変更する方法

意外とわからなかったのでメモ。

最近の Visual Studio(少なくとも 2013)で、ソリューションに新しいプロジェクトを追加するときなどの既定の言語を変える方法。 この設定は [オプション] メニューなど GUI から直接変更することはできず、[設定のインポートとエクスポート] を使用して設定を変更する必要がある。具体的には、「Environment_NewProjectDialogPreferredLanguage」という名前のカテゴリの「NewProjectDialogPreferredLanguage」と「HasNewProjectDialogPreferredLanguage」というプロパティを設定する必要がある。

手順としては以下のような感じ。

  1. 追加したい言語の既定の設定から、「NewProjectDialogPreferredLanguage」を調べる。具体的には、%Program Files(x86)%Microsoft Visual Studio 12.0\Common7\IDE\Profiles\ の下にある、好きな言語の設定をテキストエディタで調べて、「」で検索してその値をメモっておく。
  2. [ツール] の [設定のインポートとエクスポート]を使って、現在の設定を好きな場所にエクスポートする。既定では %UserProfile%\Documents\Visual Studio 2013\Settings とかにはかれる。
  3. 出力したファイルをテキストエディタで開いて、で検索。その値が false になっていたら true に変える(「全般的な開発設定」とかでインストールしていると false になっている)