- 許可されるのは一つのファイルだけ(CS8802エラー)
- 名前空間の宣言の後に文を書くとエラー(CS8803エラー)
- クラス宣言の後に文を書くとエラー(CS8803エラー)
- グローバル名前空間に
Programというクラスを生成するので、同名のクラスが存在するとエラーpartialを付けるとコンパイルが通る
- メソッド宣言はOK
- 自動生成される
Programクラスのstaticメンバーとして扱われる
- 自動生成される
- ただし、名前はコンパイル時に改変される( https://sharplab.io/#v2:EYLgtghglgdgNAExAagD4AEBMBGAsAKHQBYACADwAoBKEgbwF8D1sA6ZgTmoG4DKqfCAZhJYSAYToFG+IA== )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics.Tracing; | |
| using System.Text.Json; | |
| using var m = new System.Diagnostics.Metrics.Meter("m1"); | |
| using var evlistener = new MyEventListener(); | |
| // var c1 = m.CreateCounter<int>("c1"); | |
| var h1 = m.CreateHistogram<int>("h1"); | |
| Console.WriteLine($"1"); | |
| h1.Record(1, new KeyValuePair<string, object?>("htag1", 1)); | |
| Console.WriteLine($"2"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics.Metrics; | |
| { | |
| Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().Id); | |
| using var meter = new Meter("appmeter"); | |
| int obscnt = 1; | |
| var counter = meter.CreateCounter<int>("counter1", "unit", "desc"); | |
| var histo = meter.CreateHistogram<int>("histogram1", "unit", "desc"); | |
| var gauge = meter.CreateObservableGauge<int>("gauge1", () => 2, "unit2", "desc2"); | |
| var obscounter = meter.CreateObservableCounter<int>("obscounter1", () => { obscnt+=2;return obscnt; }, "unit2", "desc2"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics.Metrics; | |
| { | |
| Console.WriteLine(System.Diagnostics.Process.GetCurrentProcess().Id); | |
| using var meter = new Meter("app3meter"); | |
| var counter = meter.CreateCounter<int>("histogram1", "unit", "desc"); | |
| async Task CounterTask(CancellationToken ct) | |
| { | |
| int count = 2; | |
| int tagval = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.IO; | |
| using System.Diagnostics; | |
| using System; | |
| using System.Threading.Tasks; | |
| using System.Threading; | |
| namespace Diagnosticable | |
| { | |
| public class DiagnosticableStream : Stream | |
| { |
検証は主にVS2022preとdotnet-sdk-6pre
https://docs.microsoft.com/en-us/visualstudio/msbuild/solution-filters?view=vs-2019
- MSBuild 16.7から
- VSの"Save as Solution Filter"で保存されるファイルのこと
- VSだと2019以降?(パッチバージョンは?)
- vscodeのC#拡張も対応している
- オープン時の一回しか読み込まない(プロジェクト追加等、slnに変更があってもslnf側には変更は反映されない)
- 依存関係はslnにあるものが反映される
- アンロードされているプロジェクトは自動的にロードされない
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace exceptionlabs | |
| { | |
| class InheritException : Exception | |
| { | |
| string _StackTrace; | |
| public InheritException(Exception exception) : base(exception.Message) | |
| { | |
| _StackTrace = exception.StackTrace + base.StackTrace; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using System; | |
| class C1 | |
| { | |
| public static async Task Main() | |
| { | |
| static async Task Hoge() | |
| { | |
| Console.WriteLine($"Hoge: 1: {Thread.CurrentThread.ManagedThreadId}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using Microsoft.Extensions.Configuration; | |
| using Microsoft.Extensions.FileProviders; | |
| namespace cfgtest | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Diagnostics; | |
| namespace activitysample | |
| { | |
| class Program | |
| { | |
| private static readonly ActivitySource _ActivitySource = new ActivitySource("actsrc1"); | |
| static void Main(string[] args) |