LoginSignup
2
0

More than 3 years have passed since last update.

C# - Windows.Data.Jsonの謎 / winmdの中身をILSpyで確認する

Last updated at Posted at 2019-12-02

Microsoftのドキュメントに書いてあるJson関連クラスのメンバが、一部そのままの名前だとコンパイルが通らない。
参照設定しているファイルが間違っているのか?

適当にそれっぽい名前に変えてみると動いた。謎・・・

クラス ドキュメント上のメンバ 実際(?)のメンバ
JsonObject Insert Add
JsonArray Append Add
JsonArray Size Count
JsonValue CreateNullValue ない?

環境

Windows10で下記を/r:オプションで指定してコンパイル
※visuals studio等でwindows sdk入れてないとwindows.winmdファイルがなくてコンパイルできないっぽい。


csc /r:C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Runtime.WindowsRuntime\v4.0_4.0.0.0__b77a5c561934e089\system.runtime.windowsruntime.dll ^
/r:C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Runtime.InteropServices.WindowsRuntime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.InteropServices.WindowsRuntime.dll ^
/r:C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll ^
"/r:C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Annotated\Windows.winmd" %*

ILSpyで確認する方法

C:\Windows\System32\WinMetadata に下記のようにメタデータ(winmdファイル)が居る。

image.png

上記の特定のファイル1個をILSpyにDrag&Dropすると見れる。

image.png

ただ、JsonValueCreateNullValueがなぜか居る・・。

ちなみに、クラスの直下にメンバーがいなくても、継承元(Base Types)に居たりする場合があるので注意。

脱線編 - 気になるWinRTの機能たち

  • Windows.Data.winmd をILSpyで見てみると、Windows.Data.Pdfなるものが居て、PDFの読み書きに使えそう。→ 試してみた →画像としての読み込みにしか使えないっぽい。
  • Windows.AI.winmd をILSpyで見てみると、Windows.AI.MachineLearningなるものが居る。VisualStudioでnugetしなくてもcsc.exeで機械学習やれちゃう?(Visual Studio自体は入れないとダメかもですが・・)
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0