Weitere ähnliche Inhalte
Ähnlich wie .NET Core とマルチプラットフォーム (20)
Kürzlich hochgeladen (10)
.NET Core とマルチプラットフォーム
- 8. Microsoft.NETCore.App
• .NET Core の依存関係のみを定義したメタ データ パッケージ
"Libuv"
"Microsoft.CodeAnalysis.CSharp " exclude="Compile"
"Microsoft.CodeAnalysis.VisualBasic " exclude="Compile"
"Microsoft.CSharp" version="4.0.1"
"Microsoft.NETCore.DotNetHostPolicy" version="1.0.1"
"Microsoft.NETCore.Runtime.CoreCLR" version="1.0.2"
"Microsoft.VisualBasic" version="10.0.1"
"NETStandard.Library" version="1.6.0"
"System.Buffers" version="4.0.0"
"System.Collections.Immutable" version="1.2.0"
"System.ComponentModel" version="4.0.1"
"System.ComponentModel.Annotations" version="4.1.0"
"System.Diagnostics.DiagnosticSource" version="4.0.0"
"System.Diagnostics.Process" version="4.1.0"
"System.Dynamic.Runtime" version="4.0.11"
"System.Globalization.Extensions" version="4.0.1"
"System.IO.FileSystem.Watcher" version="4.0.0"
"System.IO.MemoryMappedFiles" version="4.0.0"
"System.IO.UnmanagedMemoryStream" version="4.0.1"
"System.Linq.Expressions" version="4.1.0"
"System.Linq.Parallel" version="4.0.1"
"System.Linq.Queryable" version="4.0.1"
"System.Net.NameResolution" version="4.0.0"
"System.Net.Requests" version="4.0.11"
"System.Net.Security" version="4.0.0"
"System.Net.WebHeaderCollection" version="4.0.1"
"System.Numerics.Vectors" version="4.1.1"
"System.Reflection.DispatchProxy" version="4.0.1"
"System.Reflection.Metadata" version="1.3.0"
"System.Reflection.TypeExtensions" version="4.1.0"
"System.Resources.Reader" version="4.0.0"
"System.Runtime.Loader" version="4.0.0 " exclude="Compile"
"System.Security.Cryptography.Algorithms" version="4.2.0"
"System.Security.Cryptography.Encoding" version="4.0.0"
"System.Security.Cryptography.Primitives" version="4.0.0"
"System.Security.Cryptography.X509Certificates" version="4.1.0"
"System.Threading.Tasks.Dataflow" version="4.6.0"
"System.Threading.Tasks.Extensions" version="4.0.0"
"System.Threading.Tasks.Parallel" version="4.0.1"
"System.Threading.Thread" version="4.0.0"
"System.Threading.ThreadPool" version="4.0.10"
- 10. Microsoft.NETCore.Jit
• プラットフォームごとのランタイム パッケージへの定義のみ
runtime.json (コンパイル ターゲットによって切り替える)
{
"runtimes": {
"win7-x64": {
"Microsoft.NETCore.Jit": {
"runtime.win7-x64.Microsoft.NETCore.Jit": "1.0.2"
}
},
"win7-x86": {
"Microsoft.NETCore.Jit": {
"runtime.win7-x86.Microsoft.NETCore.Jit": "1.0.2"
}
},
"debian.8-x64": {
"Microsoft.NETCore.Jit": {
"runtime.debian.8-x64.Microsoft.NETCore.Jit": "1.0.2"
}
},
- 11. Microsoft.NETCore.Windows.ApiSets
• プラットフォームごとのランタイム パッケージへの定義のみ
runtime.json (コンパイル ターゲットによって切り替える)
{
"runtimes": {
"win10": {
"Microsoft.NETCore.Windows.ApiSets": {}
},
"win7-x64": {
"Microsoft.NETCore.Windows.ApiSets": {
"runtime.win7-x64.Microsoft.NETCore.Windows.ApiSets": "1.0.1"
}
},
"win7-x86": {
"Microsoft.NETCore.Windows.ApiSets": {
"runtime.win7-x86.Microsoft.NETCore.Windows.ApiSets": "1.0.1"
}
},
- 12. NETStandard.Library 1/3
• .NET Core の BCL に相当するメタ データ パッケージ
• この場合は、dnxcore50 なので Universal Windows Platform となり、NET Standard 1.3
"Microsoft.NETCore.Platforms" version="1.0.1" ランタイム ターゲットによる切り替え情報
"Microsoft.Win32.Primitives" version="4.0.1"
"System.AppContext" version="4.1.0"
"System.Collections" version="4.0.11"
"System.Collections.Concurrent" version="4.0.12"
"System.Console" version="4.0.0"
"System.Diagnostics.Debug" version="4.0.11"
"System.Diagnostics.Tools" version="4.0.1"
"System.Diagnostics.Tracing" version="4.1.0"
"System.Globalization" version="4.0.11"
"System.Globalization.Calendars" version="4.0.1"
"System.IO" version="4.1.0"
"System.IO.Compression" version="4.1.0"
"System.IO.Compression.ZipFile" version="4.0.1"
- 13. NETStandard.Library 2/3
"System.IO.FileSystem" version="4.0.1"
"System.IO.FileSystem.Primitives" version="4.0.1"
"System.Linq" version="4.1.0"
"System.Linq.Expressions" version="4.1.0"
"System.Net.Http" version="4.1.0"
"System.Net.Primitives" version="4.0.11"
"System.Net.Sockets" version="4.1.0"
"System.ObjectModel" version="4.0.12"
"System.Reflection" version="4.1.0"
"System.Reflection.Extensions" version="4.0.1"
"System.Reflection.Primitives" version="4.0.1"
"System.Resources.ResourceManager" version="4.0.1"
"System.Runtime" version="4.1.0"
"System.Runtime.Extensions" version="4.1.0"
"System.Runtime.Handles" version="4.0.1"
"System.Runtime.InteropServices" version="4.1.0"
"System.Runtime.InteropServices.RuntimeInformation" version="4.0.0"
"System.Runtime.Numerics" version="4.0.1"
- 14. NETStandard.Library 3/3
"System.Security.Cryptography.Algorithms" version="4.2.0"
"System.Security.Cryptography.Encoding" version="4.0.0"
"System.Security.Cryptography.Primitives" version="4.0.0"
"System.Security.Cryptography.X509Certificates" version="4.1.0"
"System.Text.Encoding" version="4.0.11"
"System.Text.Encoding.Extensions" version="4.0.11"
"System.Text.RegularExpressions" version="4.1.0"
"System.Threading" version="4.0.11"
"System.Threading.Tasks" version="4.0.11"
"System.Threading.Timer" version="4.0.1"
"System.Xml.ReaderWriter" version="4.0.11"
"System.Xml.XDocument" version="4.0.11"
- 15. Microsoft.NETCore.Runtime.CoreCLR
• プラットフォームごとのランタイム パッケージへの定義のみ
runtime.json (コンパイル ターゲットによって切り替える)
{
"runtimes": {
"win8-arm": {
"Microsoft.NETCore.Runtime.CoreCLR": {
"runtime.win8-arm.Microsoft.NETCore.Runtime.CoreCLR": "1.0.2-rc3-24212-01"
}
},
"win7-x64": {
"Microsoft.NETCore.Runtime.CoreCLR": {
"runtime.win7-x64.Microsoft.NETCore.Runtime.CoreCLR": "1.0.2"
}
},
"win7-x86": {
"Microsoft.NETCore.Runtime.CoreCLR": {
"runtime.win7-x86.Microsoft.NETCore.Runtime.CoreCLR": "1.0.2"
}
},
- 16. .NET Core と BCL の関係
• さようなら mscorlib.dll
• ようこそ System.Runtime.dll
• BCL 全体を管理するメタ データ パッケージ
.NET Standard Library
• 依存関係の管理
• ターゲット プラットフォームの管理
- 17. .NET Standard Library とは何か
• 次世代の PCL (Portable Class Library)
• .NET Core ランタイム上で動作する BCL を実現させるもの
メタデータ パッケージ
• PCL との類似点
• バイナリ コードを共有できる API 定義
• PCL との相違点
• PCL がプラットフォーム間の共通部分に焦点を当てているのに対して、
API セットに焦点を当てている
• バージョン管理がシンプルなのに対して、PCL は複雑 (番号管理)
• プラットフォームに依存しない目的に対して、PCL プロファイルは
Microsoft プラットフォームを目的にしている
- 19. .NET Standard Library
プラットフォーム 別名
.NET Standard netstandard 1.0 1.1 1.2 1.3 1.4 1.5 1.6
.NET Core netcoreapp → → → → → → 1.0
.NET Framework net → 4.5 4.5.1 4.6 4.6.1 4.6.2 4.6.3
Mono/Xamarin Platforms → → → → → → *
Universal Windows Platform uap → → → → 10.0
Windows win → 8.0 8.1
Windows Phone wpa → → 8.1
Windows Phone Silverlight wp 8.0 →
- 20. Target Framework バージョン
Framework 最新
バージョン
Target
Framework
Moniker(TFM)
Compact Target
Framework
Moniker(TFM)
.NET
Standard
バージョン
メタ データ パッケージ
.NET Standard 1.6 .NETStandard,
Version=1.6
netstandard1.6 N/A NETStandardLibrary
.NET Core
Application
1.0 .NETCoreApp,
Version=1.0
netcoreapp1.0 1.5 Microsoft.NETCore.App
.NET Framework 4.6.3 .NETFramework,
Version=4.6.3
net463 1.4 N/A
- 21. PCL との互換性
• .NET Standard Library 1.0、1.1、1.2 は PCL プロファイルと互換がある
• Microsoft.NETCore.Portable.Compatobility
名前 .NET Portable Subset
Profile 7 .NET Framework 4.5, Windows 8 1.1
Profile 3.1 Windows 8.1, Windows Phone Silverlight 8.1 1.0
Profile 3.2 Windows 8.1, Windows Phone 8.1 1.2
Profile 44 .NET Framework 4.5.1, Windows 8.1 1.2
Profile 49 .NET Framework 4.5, Windows Phone Silverlight 8 1.0
Profile 78 .NET Framework 4.5, Windows 8, Windows Phone Silverlight 8 1.0
Profile 84 Windows Phone 8.1, Windows Phone Silverlight 8.1 1.0
Profile 111 .NET Framework 4.5, Windows 8, Windows Phone Silverlight 8.1 1.1
Profile 151 .NET Framework 4.5.1, Windows 8.1, Windows Phone 8.1 1.2
Profile 157 Windows 8.1, Windows Phone 8.1, Windows Phone Silverlight 8.1 1.0
Profile 259 .NET Framework 4.5, Windows 8, Windows Phone 8.1, Windows Phone Silverlight 8 1.0
- 22. .NET Standard Library とは
• マルチ プラットフォームへ対応するための新しい PCL
• 従来までの PCL とは異なるアプローチ
• nuget バージョン 3.x が必須のアプローチ
- 24. メタデータ 1/2
Token Version Flags PublicKey Name Culture HashValue
23000001 4.1.0.0 0 b03f5f7f11d50a3a System.Runtime
23000002 4.0.0.0 0 b03f5f7f11d50a3a System.Console
AssemblyRef(0x23)
Token ResolutionScope Name Namespace
01000003 23000001 DebuggableAttribute System.Diagnostics
…
01000008 23000001 Object System
01000009 23000002 Console System
TypeRef(0x01)
TypeRef メタデータは、ResolusionScope によってアセンブリを特定する
AssemblyRef メタデータは、アセンブリ識別子を記録している
- 25. メタデータ 2/2
Token ResolutionScope Name Namespace
01000003 23000001 DebuggableAttribute System.Diagnostics
…
01000008 23000001 Object System
01000009 23000002 Console System
TypeRef(0x01)
Token MemberRefParent Name Signature
0a000001 01000001 .ctor 0x20010108 (引数1、I4、void)
…
0a000007 01000009 WriteLine 0x0001010e (引数1、string、void)
0a000008 01000009 ReadLine 0x00000e (引数無し、string)
MemberRef(0x0a)
シグネチャは、メソッドの呼び出し規約、パラメータ、戻り値などを符号化した値
シグネチャによって、オーバーロードされたメソッドを特定できる
- 26. Bait and Switch
• 型を参照することをメタデータでは
• アセンブリ参照(アセンブリ識別子)
• 型(クラス)名
• メソッド名とメソッド シグネチャ
• パッケージ システムを使ったテクニック
• コンパイル時は、メタデータのみを解決
• 配布時にプラットフォーム固有のアセンブリに置き換える
• メタデータの特徴を活用したテクニック
• AssemblyRef, TypeRef, MemberRef
- 27. まとめ
• .NET Core は パッケージングによってマルチ プラットフォー
ムへ対応
• nuget 3.x がパッケージ 管理
• .NET Standard Library
• 依存関係を管理するメタ データ パッケージ
• パッケージ
• コンパイル時に参照する PCL
• 配布時に使用するプラットフォーム依存 PCL
- 29. メソッド シグネチャ
呼び出し規約の論理和
0x20 HASTHIS, 0x00 DEFAULT, 0x10 GENERIC, 0x05 VARARG,
0x40 EXPLICITHIS
ジェネリックのパラメータ数 (int32 符号化数字、2-4バイト)
ジェネリックでなければ省略される
パラメータ数 (int32 符号化数字、2-4バイト)
戻り値の型
0x01 void, 0x0e string, 0x02 bool, 0x08 i4
パラメータの型 (パラメータの数だけ繰り返す)