diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9a60615..c0df489 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal -ARG VARIANT="6.0-bullseye" +ARG VARIANT="7.0-bullseye" FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT} # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8504e97..b8a0faa 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "VARIANT": "6.0", + "VARIANT": "7.0", "NODE_VERSION": "lts/*" } }, diff --git a/.gitpod.yml b/.gitpod.yml index d17cbdf..1be9dbf 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,7 +1,7 @@ -image: gitpod/workspace-dotnet-lts:latest +image: gitpod/workspace-dotnet:latest tasks: - - name: dotnet restore - init: make restore + - name: install task + init: go install github.com/go-task/task/v3/cmd/task@latest vscode: extensions: - muhammad-sammy.csharp diff --git a/Makefile b/Makefile deleted file mode 100644 index ce48555..0000000 --- a/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -ifdef ComSpec - SEP=\\ -else - SEP=/ -endif - -DOTNETCMD=dotnet -DOTNETBUILD=$(DOTNETCMD) build -DOTNETCLEAN=$(DOTNETCMD) clean -DOTNETTEST=$(DOTNETCMD) test -DOTNETRUN=$(DOTNETCMD) run - -CUI_PROJ_NAME=TryCSharp.Tools.Cui -CUI_PROJ_PATH=$(CUI_PROJ_NAME)$(SEP)$(CUI_PROJ_NAME).csproj - -.PHONY: all -all: clean build test - -.PHONY: build -build: restore - $(DOTNETBUILD) --nologo -v q - -.PHONY: test -test: restore - $(DOTNETTEST) - -.PHONY: clean -clean: restore - $(DOTNETCLEAN) --nologo -v q - -.PHONY: run -run: clean - $(DOTNETRUN) --project $(CUI_PROJ_PATH) --onetime - -.PHONY: restore -restore: - $(DOTNETCMD) restore -v q diff --git a/README.md b/README.md index 0867553..87dd4f2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # try-csharp -This is my TUTORIAL project for csharp. (dotnet core) +This is my TUTORIAL project for csharp. -![try-csharp - DotNet Version](https://img.shields.io/badge/dotnet-6.0-blue.svg) +![try-csharp - DotNet Version](https://img.shields.io/badge/dotnet-7.0-blue.svg) [![CodeFactor](https://www.codefactor.io/repository/github/devlights/try-csharp/badge)](https://www.codefactor.io/repository/github/devlights/try-csharp) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/devlights/try-csharp) @@ -9,49 +9,66 @@ This is my TUTORIAL project for csharp. (dotnet core) ```sh $ dotnet --info -.NET SDK (reflecting any global.json): - Version: 6.0.100 - Commit: 9e8b04bbff +.NET SDK: + Version: 7.0.100 + Commit: e12b7af219 Runtime Environment: OS Name: ubuntu - OS Version: 20.04 + OS Version: 22.04 OS Platform: Linux - RID: ubuntu.20.04-x64 - Base Path: /home/gitpod/dotnet/sdk/6.0.100/ + RID: ubuntu.22.04-x64 + Base Path: /home/gitpod/dotnet/sdk/7.0.100/ -Host (useful for support): - Version: 6.0.0 - Commit: 4822e3c3aa +Host: + Version: 7.0.0 + Architecture: x64 + Commit: d099f075e4 .NET SDKs installed: - 6.0.100 [/home/gitpod/dotnet/sdk] + 7.0.100 [/home/gitpod/dotnet/sdk] .NET runtimes installed: - Microsoft.AspNetCore.App 6.0.0 [/home/gitpod/dotnet/shared/Microsoft.AspNetCore.App] - Microsoft.NETCore.App 6.0.0 [/home/gitpod/dotnet/shared/Microsoft.NETCore.App] -``` + Microsoft.AspNetCore.App 7.0.0 [/home/gitpod/dotnet/shared/Microsoft.AspNetCore.App] + Microsoft.NETCore.App 7.0.0 [/home/gitpod/dotnet/shared/Microsoft.NETCore.App] -## Run (IDE) -+ set TryCSharp.Tools.Cui project as 'startup project' -+ run onto IDE +Other architectures found: + None -## Run (CLI) +Environment variables: + DOTNET_ROOT [/home/gitpod/dotnet] + +global.json file: + Not found +``` + +## Environments ```sh -$ cd TryCSharp.Tools.Cui -$ dotnet run +$ lsb_release -a +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 22.04.2 LTS +Release: 22.04 +Codename: jammy ``` -or +## Requirements + +### [go-task](https://taskfile.dev/) ```sh -$ cd TryCSharp.Tools.Cui -$ dotnet run --onetime +$ go install github.com/go-task/task/v3/cmd/task@latest ``` -or +## Run (IDE) + ++ set TryCSharp.Tools.Cui project as 'startup project' ++ run onto IDE + +## Run (CLI) ```sh -$ make run +$ task run +task: [run] dotnet run --project TryCSharp.Tools.Cui --onetime ``` diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..254fb1f --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,17 @@ +# https://taskfile.dev + +version: "3" + +tasks: + default: + cmds: + - task: run + build: + cmds: + - dotnet build + clean: + cmds: + - dotnet clean + run: + cmds: + - dotnet run --project TryCSharp.Tools.Cui --onetime diff --git a/TryCSharp.Common/TryCSharp.Common.csproj b/TryCSharp.Common/TryCSharp.Common.csproj index 6be5b8d..711b1a6 100644 --- a/TryCSharp.Common/TryCSharp.Common.csproj +++ b/TryCSharp.Common/TryCSharp.Common.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 TryCSharp.Common latest TryCSharp.Common diff --git a/TryCSharp.Samples/Basic/BitConverterSamples01.cs b/TryCSharp.Samples/Basic/BitConverterSamples01.cs index 814510e..94b7e1f 100644 --- a/TryCSharp.Samples/Basic/BitConverterSamples01.cs +++ b/TryCSharp.Samples/Basic/BitConverterSamples01.cs @@ -36,7 +36,7 @@ public void Execute() bytes = new byte[] {1, 0, 0, 0}; Output.WriteLine(BitConverter.ToInt32(bytes, 0)); - bytes = BitConverter.GetBytes((byte) 'a'); + bytes = BitConverter.GetBytes((short) 'a'); Output.WriteLine(BitConverter.ToChar(bytes, 0)); } } diff --git a/TryCSharp.Samples/Threading/ThreadLocalSamples01.cs b/TryCSharp.Samples/Threading/ThreadLocalSamples01.cs index 70e748d..1befcf2 100644 --- a/TryCSharp.Samples/Threading/ThreadLocalSamples01.cs +++ b/TryCSharp.Samples/Threading/ThreadLocalSamples01.cs @@ -22,7 +22,7 @@ public void Execute() // ・フィールドの値は常に、その型のデフォルト値で初期化される。初期値を設定しても無視される。 // // ThreadLocalは、上記の点を解決している。つまり - // ・インスタンスフィールドに対応している。 + // ・インスタンスフィールドに対応している。(が、警告が出る) // ・フィールドの値を初期値で初期化出来る。 // // 利用方法は、System.Lazyと似ており、コンストラクタに初期化のためのデリゲートを渡す。 @@ -66,46 +66,7 @@ public void Execute() countdown.Wait(); } - // - // インスタンスフィールドのThreadStatic属性の確認 - // ThreadStatic属性は、インスタンスフィールドに対しては効果が無い。 - // なので、出力される値は2,3,4,5,6...とインクリメントされていく. - // - using (var countdown = new CountdownEvent(numberOfParallels)) - { - for (var i = 0; i < numberOfParallels; i++) - { - new Thread(() => - { - Output.WriteLine("ThreadStatic [count3]>>> {0}", count3++); - countdown.Signal(); - }).Start(); - } - - countdown.Wait(); - } - - // - // インスタンスフィールドのThreadLocalの確認 - // ThreadLocalは、インスタンスフィールドに対しても問題なく利用できる。 - // なので、出力される値は4となる。 - // - using (var countdown = new CountdownEvent(numberOfParallels)) - { - for (var i = 0; i < numberOfParallels; i++) - { - new Thread(() => - { - Output.WriteLine("ThreadLocal [count4]>>> {0}", count4.Value++); - countdown.Signal(); - }).Start(); - } - - countdown.Wait(); - } - count2.Dispose(); - count4.Dispose(); } #region Static Fields @@ -116,14 +77,5 @@ public void Execute() private static readonly ThreadLocal count2 = new ThreadLocal(() => 2); #endregion - - #region Fields - - // ReSharper disable once ThreadStaticAtInstanceField - [ThreadStatic] private int count3 = 2; - - private readonly ThreadLocal count4 = new ThreadLocal(() => 4); - - #endregion } } \ No newline at end of file diff --git a/TryCSharp.Samples/TryCSharp.Samples.csproj b/TryCSharp.Samples/TryCSharp.Samples.csproj index 5536738..6402766 100644 --- a/TryCSharp.Samples/TryCSharp.Samples.csproj +++ b/TryCSharp.Samples/TryCSharp.Samples.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 TryCSharp.Samples latest TryCSharp.Samples diff --git a/TryCSharp.Tools.Cui/TryCSharp.Tools.Cui.csproj b/TryCSharp.Tools.Cui/TryCSharp.Tools.Cui.csproj index df82e53..b2e42ed 100644 --- a/TryCSharp.Tools.Cui/TryCSharp.Tools.Cui.csproj +++ b/TryCSharp.Tools.Cui/TryCSharp.Tools.Cui.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 TryCSharp.Tools.Cui latest TryCSharp.Tools.Cui