Files
.infineon/_-Review/dotnet.md
2024-11-25 23:41:54 -07:00

220 lines
8.7 KiB
Markdown

---
created: 2024-02-25T00:52:01.425Z
type: topic
updated: 2024-11-25T20:45:14.336Z
---
# dotnet
```c#
public int Index { get; set; }
public int I⁀ndex { get; set; }
```
```bash
# https://learn.microsoft.com/en-us/dotnet/core/extensions/windows-service?pivots=dotnet-7-0#create-the-windows-service
sc.exe create "File-Watcher-ISO" binpath="C:\Users\Phares\AppData\Local\IFXApps\File-Watcher-ISO\File-Watcher.exe"
sc.exe create "File-Watcher-Compass" binpath="L:\DevOps\Mesa_FI\File-Watcher\bin\Release\net8.0\win-x64\publish\File-Watcher.exe"
sc.exe create "File-Watcher" binpath="C:\Windows\System32\config\systemprofile\AppData\Local\IFXApps\File-Watcher\File-Watcher.exe"
sc.exe create "Directory-Size" binpath="C:\Windows\System32\config\systemprofile\AppData\Local\IFXApps\Directory-Size\Directory-Size.exe"
sc.exe create "Parsing-Packets" binpath="C:\Windows\System32\config\systemprofile\AppData\Local\IFXApps\Parsing-Packets\Parsing-Packets.exe"
```
```conf Tue Jan 02 2024 10:01:33 GMT-0700 (Mountain Standard Time)
dotnet_diagnostic.CA1816.severity = none # CA1816: Call GC.SuppressFinalize correctly
dotnet_diagnostic.CA1854.severity = warning # CA1854: Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup
dotnet_diagnostic.CA1866.severity = none # CA1866: Use 'string.EndsWith(char)' instead of 'string.EndsWith(string)' when you have a string with a single char
dotnet_diagnostic.IDE0200.severity = warning # IDE0200: Lambda expression can be removed [Map]
```
```bash Fri Jan 05 2024 19:24:13 GMT-0700 (Mountain Standard Time)
dotnet add package Microsoft.Extensions.Hosting.Systemd --version 8.0.0
```
```c#
// https://blog.maartenballiauw.be/post/2021/05/25/running-a-net-application-as-a-service-on-linux-with-systemd.html
// https://stackoverflow.com/questions/71233335/use-systemd-on-asp-net-core-6-0-and-7-0
Host.CreateDefaultBuilder(args)
.UseSystemd() // add this
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
});
```
```bash
nano /etc/systemd/system/text-2-json.service
systemctl daemon-reload
systemctl status text-2-json.service
systemctl enable text-2-json.service
systemctl stop text-2-json.service
systemctl start text-2-json.service
systemctl restart text-2-json.service
systemctl status text-2-json.service
journalctl -u text-2-json.service
```
```conf
[Unit]
Description=Text 2 json
[Service]
Type=notify
ExecStart=/usr/sbin/text-2-json --port=53
[Install]
WantedBy=multi-user.target
```
```conf Mon Jan 08 2024 10:23:04 GMT-0700 (Mountain Standard Time)
dotnet_diagnostic.IDE0074.severity = warning # IDE0074: Use compound assignment
dotnet_diagnostic.IDE0058.severity = warning # IDE0058: Expression value is never used
dotnet_diagnostic.CA1511.severity = warning # CA1511: Use 'ArgumentException.ThrowIfNullOrEmpty' instead of explicitly throwing a new exception instance
dotnet_diagnostic.CA1862.severity = warning # CA1862: Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison, but keep in mind that this might cause subtle changes in behavior, so make sure to conduct thorough testing after applying the suggestion, or if culturally sensitive comparison is not required, consider using 'StringComparison.OrdinalIgnoreCase'
```
```conf Sun Feb 04 2024 14:03:10 GMT-0700 (Mountain Standard Time)
dotnet_diagnostic.CA1513.severity = none # Use 'ObjectDisposedException.ThrowIf' instead of explicitly throwing a new exception instance
```
```bash
dotnet dev-certs https --trust
set DOTNET_CLI_TELEMETRY_OPTOUT=1
setx DOTNET_CLI_TELEMETRY_OPTOUT 1
```
```bash
dotnet user-secrets list
cat ./input.json | dotnet user-secrets set
```
```C#
// https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options
// csharp_new_line_before_open_brace = all
void MyMethod()
{
if (...)
{
...
}
}
// csharp_new_line_before_open_brace = none
void MyMethod() {
if (...) {
...
}
}
```
```json
// https://github.com/editorconfig-checker/editorconfig-checker
{
"scripts": {
"prettier.check": "prettier . --check",
"prettier.write": "prettier . --write",
"lint:editorconfig": "editorconfig-checker"
},
"devDependencies": {
"editorconfig-checker": "^5.1.5",
"prettier": "3.0.0"
}
}
```
```conf Wed Mar 20 2024 17:29:08 GMT-0700 (Mountain Standard Time)
# https://johnnyreilly.com/eslint-your-csharp-in-vs-code-with-roslyn-analyzers
# <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
dotnet_analyzer_diagnostic.category-Design.severity = error
dotnet_analyzer_diagnostic.category-Documentation.severity = error
dotnet_analyzer_diagnostic.category-Globalization.severity = none
dotnet_analyzer_diagnostic.category-Interoperability.severity = error
dotnet_analyzer_diagnostic.category-Maintainability.severity = error
dotnet_analyzer_diagnostic.category-Naming.severity = none
dotnet_analyzer_diagnostic.category-Performance.severity = none
dotnet_analyzer_diagnostic.category-Reliability.severity = error
dotnet_analyzer_diagnostic.category-Security.severity = error
dotnet_analyzer_diagnostic.category-SingleFile.severity = error
dotnet_analyzer_diagnostic.category-Style.severity = error
dotnet_analyzer_diagnostic.category-Usage.severity = error
dotnet_diagnostic.CA2201.severity = none # CA2201: Exception type System.NullReferenceException is reserved by the runtime
dotnet_diagnostic.IDE0010.severity = none # Add missing cases to switch statement (IDE0010)
dotnet_diagnostic.IDE0048.severity = none # Parentheses preferences (IDE0047 and IDE0048)
dotnet_diagnostic.IDE0130.severity = none # Namespace does not match folder structure (IDE0130)
```
```conf Tue Apr 02 2024 20:34:52 GMT-0700 (Mountain Standard Time)
dotnet_diagnostic.IDE0051.severity = error # Private member '' is unused [, ]
```
```conf Sun Apr 28 2024 09:27:55 GMT-0700 (Mountain Standard Time)
dotnet_diagnostic.CA1001.severity = error # CA1001: Types that own disposable fields should be disposable
dotnet_diagnostic.CA1051.severity = error # CA1051: Do not declare visible instance fields
```
```conf Tue May 07 2024 09:27:28 GMT-0700 (Mountain Standard Time)
dotnet_diagnostic.CA1861.severity = none # CA1861: Prefer 'static readonly' fields over constant array arguments
```
```conf Sat May 11 2024 15:40:59 GMT-0700 (Mountain Standard Time)
dotnet_diagnostic.JSON002.severity = warning # JSON002: Probable JSON string detected
dotnet_diagnostic.IDE0230.severity = warning # IDE0230: Use UTF-8 string literal
```
```bash 1731863670156 = 638674604701560000 = Sun Nov 17 2024 10:14:29 GMT-0700 (Mountain Standard Time)
# snap install dotnet-sdk --classic --channel 9.0/stable
# snap install dotnet-sdk --classic --stable
# snap remove dotnet-sdk
snap install dotnet-sdk --classic --channel latest/stable
export DOTNET_ROOT=/snap/dotnet-sdk/current
# ~/.bash_profile
# ~/.bashrc
dotnet --info
```
```bash 1732378004187 = 638679748041870000 = Sat Nov 23 2024 09:06:43 GMT-0700 (Mountain Standard Time)
wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
apt-get update
apt-get install -y dotnet-sdk-9.0
rm packages-microsoft-prod.deb
dotnet --info
```
```bash
mkdir -p ~/.microsoft/usersecrets/cc24ad7a-1d95-4c47-a3ea-0d8475ab06da
nano ~/.microsoft/usersecrets/cc24ad7a-1d95-4c47-a3ea-0d8475ab06da/secrets.json
```
```bash 1732478061005 = 638680748610050000 = Sun Nov 24 2024 12:54:20 GMT-0700 (Mountain Standard Time)
dotnet nuget why Map/Map.csproj System.Private.Uri
```
```conf 1732559357181 = 638681561571810000 = Mon Nov 25 2024 11:29:16 GMT-0700 (Mountain Standard Time)
# New line preferences
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
csharp_style_allow_embedded_statements_on_same_line_experimental = true
#### C# Formatting Rules ####
# New line preferences
csharp_new_line_before_catch = false
csharp_new_line_before_else = false
csharp_new_line_before_finally = false
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = none
csharp_new_line_between_query_expression_clauses = true
```
```conf 1732567489197 = 638681642891970000 = Mon Nov 25 2024 13:44:48 GMT-0700 (Mountain Standard Time)
#### .NET Coding Conventions ####
# Organize usings
dotnet_separate_import_directive_groups = true
dotnet_sort_system_directives_first = true
```