SlideShare a Scribd company logo
.NET Core 1.0 と
マルチプラットフォーム
Deep Dive
荒井 省三
アジェンダ
• project.json
• Microsoft.NETCoreApp
• NETStandard Libaray
• .NET Core と BCL
• 新しい PCL とは
.NET Core とは
.NET Framework .NET Core XAMARIN
アプリ
モデル
ベース
ライブラリ
.NET Core とは
.NET Framework .NET Core XAMARIN
アプリ
モデル
ベース
ライブラリ
コンソール アプリ
Project.json
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
Project.json
• platform
• Microsoft.NETCore.App
• frameworks
• netcoreapp1.0
"imports": "dnxcore50"
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"
Microsoft.NETCore.Runtime.CoreCLR
• 依存関係のみを定義したメタ データ パッケージ
"Microsoft.NETCore.Jit" version="1.0.2"
"Microsoft.NETCore.Windows.ApiSets" version="1.0.1"
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"
}
},
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"
}
},
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"
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"
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"
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"
}
},
.NET Core と BCL の関係
• さようなら mscorlib.dll
• ようこそ System.Runtime.dll
• BCL 全体を管理するメタ データ パッケージ
.NET Standard Library
• 依存関係の管理
• ターゲット プラットフォームの管理
.NET Standard Library とは何か
• 次世代の PCL (Portable Class Library)
• .NET Core ランタイム上で動作する BCL を実現させるもの
メタデータ パッケージ
• PCL との類似点
• バイナリ コードを共有できる API 定義
• PCL との相違点
• PCL がプラットフォーム間の共通部分に焦点を当てているのに対して、
API セットに焦点を当てている
• バージョン管理がシンプルなのに対して、PCL は複雑 (番号管理)
• プラットフォームに依存しない目的に対して、PCL プロファイルは
Microsoft プラットフォームを目的にしている
PCL プロファイル 151
.NET framework
4.5.1
Windows 8.1
Windows
Phone 8.1
.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 →
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
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
.NET Standard Library とは
• マルチ プラットフォームへ対応するための新しい PCL
• 従来までの PCL とは異なるアプローチ
• nuget バージョン 3.x が必須のアプローチ
型を参照するとは何か
using System;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var s = Console.ReadLine();
}
}
}
メタデータ 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 メタデータは、アセンブリ識別子を記録している
メタデータ 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)
シグネチャは、メソッドの呼び出し規約、パラメータ、戻り値などを符号化した値
シグネチャによって、オーバーロードされたメソッドを特定できる
Bait and Switch
• 型を参照することをメタデータでは
• アセンブリ参照(アセンブリ識別子)
• 型(クラス)名
• メソッド名とメソッド シグネチャ
• パッケージ システムを使ったテクニック
• コンパイル時は、メタデータのみを解決
• 配布時にプラットフォーム固有のアセンブリに置き換える
• メタデータの特徴を活用したテクニック
• AssemblyRef, TypeRef, MemberRef
まとめ
• .NET Core は パッケージングによってマルチ プラットフォー
ムへ対応
• nuget 3.x がパッケージ 管理
• .NET Standard Library
• 依存関係を管理するメタ データ パッケージ
• パッケージ
• コンパイル時に参照する PCL
• 配布時に使用するプラットフォーム依存 PCL
Appendix
メソッド シグネチャ
呼び出し規約の論理和
0x20 HASTHIS, 0x00 DEFAULT, 0x10 GENERIC, 0x05 VARARG,
0x40 EXPLICITHIS
ジェネリックのパラメータ数 (int32 符号化数字、2-4バイト)
ジェネリックでなければ省略される
パラメータ数 (int32 符号化数字、2-4バイト)
戻り値の型
0x01 void, 0x0e string, 0x02 bool, 0x08 i4
パラメータの型 (パラメータの数だけ繰り返す)
参考資料
• ISO/IEC 23271
Common Language Infrastructure (CLI)
• X 3016 : 2009 ISO/IEC 23271 : 2006
共通言語基盤 (CLI)

More Related Content

PPTX
Dot netcore multiplatform 2
PPTX
Net fringejp2016
PPTX
dotnetconfJP2017_netcore2
PPTX
C# design note sep 2014
PPTX
今から始める、Windows 10&新.NETへの移行戦略
PPTX
Modern .NET
PDF
.NET Core 1.0
PDF
.NET 5 勉強会 ~.NET Framework から .NET へ~
Dot netcore multiplatform 2
Net fringejp2016
dotnetconfJP2017_netcore2
C# design note sep 2014
今から始める、Windows 10&新.NETへの移行戦略
Modern .NET
.NET Core 1.0
.NET 5 勉強会 ~.NET Framework から .NET へ~

What's hot (20)

PDF
.NET Core 5 ~ Windows, Linux, OS X そして Docker まで ~
PPTX
C# 3.0 以降
PDF
Firefoxの開発プロセス
PDF
OpenJDK コミュニティに参加してみよう #jjug
PDF
【BS4】時は来たれり。今こそ .NET 6 へ移行する時。
PPTX
.NET Compiler Platform
PDF
Open Liberty: オープンソースになったWebSphere Liberty
PPTX
(ゲームじゃない方の)switchで遊びたい話
PPTX
OpenShift from Easy way to Hard ? Way
PDF
DEV-002_.NET Core/ASP.NET Core が実現するクロスプラットフォーム .NET の今と未来
PPTX
C# 8.0 非同期ストリーム
PDF
jjugccc2018 app review postmortem
PDF
Recap: PowerShell Core
PDF
Windows PowerShell によるWindows Server 管理の自動化 v4.0 2014.03.13 更新版
PDF
Getting Started GraalVM / GraalVM超入門 #jjug_ccc #ccc_c2
PDF
phpspecで始めるBDD
PDF
はてなにおける継続的デプロイメントの現状と Docker の導入
PDF
Mozillaのビルドインフラ
PPTX
microPCFを使ってみよう
PPTX
PowerShell の基本操作とリモーティング&v3のご紹介 junichia
.NET Core 5 ~ Windows, Linux, OS X そして Docker まで ~
C# 3.0 以降
Firefoxの開発プロセス
OpenJDK コミュニティに参加してみよう #jjug
【BS4】時は来たれり。今こそ .NET 6 へ移行する時。
.NET Compiler Platform
Open Liberty: オープンソースになったWebSphere Liberty
(ゲームじゃない方の)switchで遊びたい話
OpenShift from Easy way to Hard ? Way
DEV-002_.NET Core/ASP.NET Core が実現するクロスプラットフォーム .NET の今と未来
C# 8.0 非同期ストリーム
jjugccc2018 app review postmortem
Recap: PowerShell Core
Windows PowerShell によるWindows Server 管理の自動化 v4.0 2014.03.13 更新版
Getting Started GraalVM / GraalVM超入門 #jjug_ccc #ccc_c2
phpspecで始めるBDD
はてなにおける継続的デプロイメントの現状と Docker の導入
Mozillaのビルドインフラ
microPCFを使ってみよう
PowerShell の基本操作とリモーティング&v3のご紹介 junichia
Ad

Viewers also liked (20)

PDF
What, Why, How Create OSS Libraries - 過去に制作した30のライブラリから見るC#コーディングテクニックと個人OSSの...
PDF
Beachhead implements new opcode on CLR JIT
PDF
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
PPTX
RuntimeUnitTestToolkit for Unity
PDF
NextGen Server/Client Architecture - gRPC + Unity + C#
PDF
マイクロサービスバックエンドAPIのためのRESTとgRPC
PPTX
Azure Storage Partition Internals
PDF
.NET Coreとツール類の今
PDF
Photon Server Deep Dive - PhotonWireの実装から見つめるPhotonServerの基礎と応用
PPTX
Memcachedの仕組みと設定
PDF
Functional go
PDF
ZeroFormatter/MagicOnion - Fastest C# Serializer/gRPC based C# RPC
PDF
MySQLの文字コード事情
PDF
Goをカンストさせる話
PDF
Goでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 Spring
PPTX
HoloLens x Graphics 入門
PPTX
Plen2で始めるロボット制御の基本
PDF
Androidとの同時開発だけどモデルをC++で書けば問題ないよねっ
PPTX
2015 0227 OSC-Spring Tokyo NETMF
PDF
C++ と Visual Studio による Android 開発
What, Why, How Create OSS Libraries - 過去に制作した30のライブラリから見るC#コーディングテクニックと個人OSSの...
Beachhead implements new opcode on CLR JIT
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
RuntimeUnitTestToolkit for Unity
NextGen Server/Client Architecture - gRPC + Unity + C#
マイクロサービスバックエンドAPIのためのRESTとgRPC
Azure Storage Partition Internals
.NET Coreとツール類の今
Photon Server Deep Dive - PhotonWireの実装から見つめるPhotonServerの基礎と応用
Memcachedの仕組みと設定
Functional go
ZeroFormatter/MagicOnion - Fastest C# Serializer/gRPC based C# RPC
MySQLの文字コード事情
Goをカンストさせる話
Goでヤフーの分散オブジェクトストレージを作った話 Go Conference 2017 Spring
HoloLens x Graphics 入門
Plen2で始めるロボット制御の基本
Androidとの同時開発だけどモデルをC++で書けば問題ないよねっ
2015 0227 OSC-Spring Tokyo NETMF
C++ と Visual Studio による Android 開発
Ad

Similar to .NET Core とマルチプラットフォーム (20)

PPTX
CLI と BCL
PPT
20060419
PPTX
.NETクロスプラットフォーム
PPT
20050903
PPTX
20160709 .NET Core on RHEL
PDF
Linux & Mac OS でも動く! ~ オープンソース & クロスプラットフォーム .NET の歩き方 ~
PDF
【BS2】.NET 6 最新アップデート
PDF
Dotnetcore30forwindesktop
PPT
Hello ".NET" World
PPTX
Vertica 8.0.0 新機能
PDF
ASP.NET 新時代に向けて ~ ASP.NET 5 / Visual Studio 2015 基礎解説
PPTX
.NET vNext
PPTX
ASP.NET vNextの全貌
PDF
TypeScript ファースト ステップ (v.0.9 対応版) ~ Any browser. Any host. Any OS. Open Sourc...
PDF
.NET Core と Container, そして Azure Web Apps on Linux による Web アプリ開発最前線
PDF
Getting Started .NET Core
PDF
Mvc conf session_1_osada
PDF
CEDEC 2013 Unity on Windows 8
PPT
170622 02
PDF
本格化するクラウド ネイティブに向けて進化する開発プラットフォームと .NET
CLI と BCL
20060419
.NETクロスプラットフォーム
20050903
20160709 .NET Core on RHEL
Linux & Mac OS でも動く! ~ オープンソース & クロスプラットフォーム .NET の歩き方 ~
【BS2】.NET 6 最新アップデート
Dotnetcore30forwindesktop
Hello ".NET" World
Vertica 8.0.0 新機能
ASP.NET 新時代に向けて ~ ASP.NET 5 / Visual Studio 2015 基礎解説
.NET vNext
ASP.NET vNextの全貌
TypeScript ファースト ステップ (v.0.9 対応版) ~ Any browser. Any host. Any OS. Open Sourc...
.NET Core と Container, そして Azure Web Apps on Linux による Web アプリ開発最前線
Getting Started .NET Core
Mvc conf session_1_osada
CEDEC 2013 Unity on Windows 8
170622 02
本格化するクラウド ネイティブに向けて進化する開発プラットフォームと .NET

.NET Core とマルチプラットフォーム

  • 1. .NET Core 1.0 と マルチプラットフォーム Deep Dive 荒井 省三
  • 2. アジェンダ • project.json • Microsoft.NETCoreApp • NETStandard Libaray • .NET Core と BCL • 新しい PCL とは
  • 3. .NET Core とは .NET Framework .NET Core XAMARIN アプリ モデル ベース ライブラリ
  • 4. .NET Core とは .NET Framework .NET Core XAMARIN アプリ モデル ベース ライブラリ
  • 6. Project.json { "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0" } }, "frameworks": { "netcoreapp1.0": { "imports": "dnxcore50" } } }
  • 7. Project.json • platform • Microsoft.NETCore.App • frameworks • netcoreapp1.0 "imports": "dnxcore50"
  • 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"
  • 9. Microsoft.NETCore.Runtime.CoreCLR • 依存関係のみを定義したメタ データ パッケージ "Microsoft.NETCore.Jit" version="1.0.2" "Microsoft.NETCore.Windows.ApiSets" version="1.0.1"
  • 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 プラットフォームを目的にしている
  • 18. PCL プロファイル 151 .NET framework 4.5.1 Windows 8.1 Windows Phone 8.1
  • 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 が必須のアプローチ
  • 23. 型を参照するとは何か using System; namespace ConsoleApplication { public class Program { public static void Main(string[] args) { Console.WriteLine("Hello World!"); var s = Console.ReadLine(); } } }
  • 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 パラメータの型 (パラメータの数だけ繰り返す)
  • 30. 参考資料 • ISO/IEC 23271 Common Language Infrastructure (CLI) • X 3016 : 2009 ISO/IEC 23271 : 2006 共通言語基盤 (CLI)