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 / MicrosoftExtensionsOptionsDeepDive.md
Created November 4, 2019 11:44
Deep dive of Microsoft.Extensions.Options in Japanese

Microsoft.Extensions.Options Deep Dive

最近は .NET Core の仕事をしています。

さて、ASP.NET Core を使っていると、とりあえず構成情報みたいなものは IOptions<TOptions> で受け取っておけみたいな雑な話を目にします。 一応 公式のドキュメント はあるのですが、正直読んでもよくわからない。柔軟なんだねー、なるほどねーみたいな感じになりました。なので、ここではできる限り(?)網羅的に解説してみようと思います。

  • IOptions<TOptions> って何?(TOptions を直接注入すればいいじゃん)
  • IOptionsSnapshot<TOptions> とかたくさんあってよくわかんない
  • オプションの動的更新に必要なものは?

.NET Coreコードリーディングことはじめ

このエントリはWindows & Microsoft技術 基礎 Advent Calendar 2015の6日目です。

.NETのトラブルシュートをしたり、実装に興味があったり、日々の仕事に疲れた心への癒やしとして、.NETの実装を見たいことがあると思います。このエントリでは、そういった方向けに簡単なガイドを提供します。

前提と対象

.NETの実装は色々あるのですが、この記事では.NET 5向けの実装についての話をします。それ以前のMicrosoft実装については、クラスライブラリ部分のみリファレンスソースとして公開されているので、そちらを参照すると良いでしょう(ランタイムそのもののソースコードは公開されていません)。ライセンスもMITライセンスなので安心です。ただし、クライアント側(Windows FormsやWPF)のコードはgithubには公開されておらず、Microsoftのサイトで公開されており、そのライセンスはMicrosoft Reference Source Licenseとなっていますので、デバッグや相互運用性の向上を目的としない使用には注意が必要です。XamarinやUnityで使っているMonoについては、素直にMonoのソースツリーを見ればいいでしょう。ただし、クラスライブラリはMITライセンスですが、ランタイムはLGPLなので、人によっては注意が必要かもしれません。

@yfakariya
yfakariya / MicrosoftExtensionsDependencyInjectionDeepDive.md
Created November 4, 2019 11:47
Deep dive of Microsoft.Extensions.DependencyInjection in Japanese

Microsoft.Extensions.DependencyInjection Deep Dive

そんなに深くない気がしますが。Microsoft.Extensions.DependencyInjection の DI についてざっくりまとめた記事です。なお、長いので、Microsoft.Extensions.DependencyInjectionM.E.DI と略します。

例によって、公式ドキュメント にすべて書いてある、はずですが、ここでは少し別の観点でまとめてみます。また、ドキュメントに書いてない(と思う)内部実装についてもいくつか書いてあります。

使い方

  • IServiceCollection の拡張メソッドを使用して、フレームワークやランタイムが提供する IServiceCollection の実装に対して登録していきます。
  • IServiceCollectionServiceDescriptor というサービスについてのスペックを表すオブジェクトのコレクションである。ServiceDescriptor はサービス型をキーにして、ライフタイムと実装を持ちます。

Flutterのパッケージを作る時のバージョンメモ

environmentについて

  • sdk は Dart SDK のバージョン(Flutter SDK ではない)
  • flutter が Flutter のバージョン

Dart SDK のバージョン

@yfakariya
yfakariya / iotedge-deep-dive-1_edgelet.md
Last active November 29, 2021 15:48
IoT Edge Deep Dive (ja) -- notes of Azure IoT Edge source code readings. See https://github.com/azure/iotedge for original source code (MIT License).

IoT Edge Deep Dive 1 -- Edgelet

IoT Edgeの中で、ホスト(つまりDockerコンテナーの外側)で動作するコンポーネントとして、IoT Edgeセキュアデーモン(iotedged)とCLI(iotedge)がある。 これらはedgeletと呼ばれるネイティブコンポーネントで動作する(ちなみに、edgeletのほとんどはRustで記述されている。HSMと直接通信する部分のみC言語で記述されている)。

IoT Edgeセキュアデーモンは、以下の役割を持つコンポーネントである。

  • HSM(Hardware Security Module)を抽象化する
  • Dockerコンテナー内で動作するIoT Edgeのモジュールに対して、モジュールのアイデンティティに関わる情報のストレージを提供する
@yfakariya
yfakariya / AzureADTerms01.md
Last active October 5, 2021 15:34
Azure ADの話

Azure ADの用語の話

メモなので、間違いなどあればコメントいただけると嬉しいです。

前提

プリンシパル(princilal)

wikipediaより。

@yfakariya
yfakariya / NoteOfImplementationOfCSharp7_8_ja.md
Created May 3, 2019 12:32
C#7やC#8の新機能の実装についてのメモ。実装とは、ILなりメタデータの表現のことを指す。

ジェネリック型パラメーターのenum制約

  • 型パラメーターの制約に System.Enum 型があるだけ
  • struct 制約は付かない。

ジェネリック型パラメーターのunmanaged制約

  • 型パラメーターにカスタム属性 System.Runtime.CompilerServices.IsUnamagedAttribute が適用されているかどうか。なお、拡張メソッドと同じく、属性の型のアセンブリ名は無視される。C# 8 previewコンパイラーは、この属性をコンパイル結果のアセンブリに生成している。
  • 型パラメーターに modreq として System.Runtime.InteropServices.UnmanagedType が指定されている。
  • struct 制約も同時に付く。
@yfakariya
yfakariya / UnifiedResponse.cs
Created August 13, 2016 07:33
PoC code (not tested) to unify view as HTML response and web API response
// Copyright(c) 2016 FUJIWARA, Yusuke
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@yfakariya
yfakariya / ReactiveProperty_NetStandard.json
Created July 9, 2016 06:58
ReactivePropertyのproject.json書いてみた
// 本体のほう
{
"version": "1.0.0-*",
"dependencies": {
"System.Runtime": "4.1.0",
"System.Collections": "4.0.11",
"System.ObjectModel": "4.0.12",
"System.Reflection": "4.1.0",
"System.Reflection.Extensions": "4.0.1",
@yfakariya
yfakariya / New_MsgPack-CLI_String_draft.md
Last active December 14, 2015 03:39
A draft of MsgPack-CLI new string implementation related to issue121 of msgpack.

About String

As of new MessagePack specification, MessagePack specified Unicode string handling. This document describes MsgPack-CLI design and implementation for it.

Current Design

Previously, the defacto-standard interpretation of MessagePack specification is Unicode string should be encoded UTF-8 without BOM and stores as Raw type. So, MsgPack-CLI is implemented as following:

  • Packer packs String (or Char sequence) as UTF-8 bytes on Raw type. Note that Packer provides overloaded methods which accepts System.Text.Encoding to specify custom character encoding.
  • Unpacker and MessagePackObject handles Raw type value as Byte[], and they provides ReadString or AsString method which handles character decoding from unpacked Raw type value.
  • MessagePackSerializer uses above primitive API as following rules: