Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NETとC#のバージョンアップ #60

Merged
merged 3 commits into from
Jul 14, 2024

Conversation

birdsea
Copy link
Contributor

@birdsea birdsea commented Sep 17, 2023

変更内容

以下のバージョンアップを行いました。

  • .NET(.NET Coreから.NETに名前が変わったようです) : .NET Core 3.1 -> .NET 7.0
  • C# : 8.0 -> 11.0

.NETのバージョンアップに伴い、使用しているライブラリもバージョンアップしています。
また、動作に影響しない範囲で以下を修正しています。

ASP.NET Coreのバージョンアップに伴う修正

C#のバージョンアップに伴う修正

その他

dotnet formatのバージョンアップに伴い、CIを修正。

  • --checkオプションがなくなり--verify-no-changesオプションになった
  • 以下の3つのサブコマンドが指定できるようになった。従来のコード整形に加え、サードパーティのコードアナライザーの問題個所も整形されるようなった。
    • whitespace : 空白や改行コードなどの整形
    • style : コード スタイルなどの整形
    • analyzers : サードパーティのアナライザーの警告箇所の整形

StyleCopの警告箇所まで一度に修正すると確認が大変だと思ったため、
今回は従来通りのコード整形の部分(whitespaceとstyle)だけCIでチェックするように修正しています。
サブコマンドを指定しないdotnet formatを実行すると、StyleCopの警告箇所も含めて整形されるので注意。


バージョンアップにより他にもリファクタリングできるところは多そう(特にC#はだいぶ書き方が変わっているところがありそうです)で、それらについては今後少しづつ改善していきます。

@birdsea birdsea self-assigned this Sep 17, 2023
@reg-suit
Copy link

reg-suit bot commented Sep 17, 2023

✨✨ That's perfect, there is no visual difference! ✨✨

Check out the report here.

}
this.title = title;
this.content = content;
post_date = DateTime.Now;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ちょっとまだ確認まで取れなかったので、いったんメモ程度にコメント書いてます。
ご提示いただいた↓リンク。
https://learn.microsoft.com/ja-jp/aspnet/core/migration/31-to-60?view=aspnetcore-7.0&tabs=visual-studio
DateTime 値は UTC 時刻としてモデル バインドされる
というのがあって、該当(JSTにならなくなるのかと)するんじゃないかと確認中です。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

バインドされる対象はリクエストパラメータになっている項目だと思います。
サーバサイドでDateTime.Nowを設定しているものはサーバのタイムゾーンに依存して設定されます。
(ローカルだとJSTで設定されますが、Heroku環境だとタイムゾーンをJSTに設定していないため、現状はUTCになっています。ここはJSTになるように修正する必要がありそうです)

上記はDiaryテーブルのpost_dateとupdate_dateの話で、
他のDBの日時項目(アカウントロック日時)は.NETのFW仕様上、固定でUTCで登録されるされるものもあり、そちらは画面表示する際にJSTに変換して表示しています。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらで確認しきる前に回答いただいてありがとうございます。
このままで大丈夫そうですね。了解しました。

Copy link
Contributor

@abe3333 abe3333 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ものすごく遅くなってしまってすみません。確認しました。
ご対応ありがとうございました。

mainメソッド廃止は、確かにあると冗長的な気はしますけど、
無いなら無いで、(関数の中に処理があるのに慣れ過ぎていて)違和感がありますね。。。

@birdsea
Copy link
Contributor Author

birdsea commented Jul 14, 2024

ありがとうございます。
寿司ゆき:smile_salmon

@birdsea birdsea merged commit e277218 into master Jul 14, 2024
3 checks passed
@birdsea birdsea deleted the feature/upgrade_dotnet_and_csharp branch July 14, 2024 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants