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

8.7 KiB

created, type, updated
created type updated
2024-02-25T00:52:01.425Z topic 2024-11-25T20:45:14.336Z

dotnet

public int Index { get; set; }

public int I⁀ndex { get; set; }
# 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"
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]
dotnet add package Microsoft.Extensions.Hosting.Systemd --version 8.0.0
// 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>();
    });
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
[Unit]
Description=Text 2 json

[Service]
Type=notify
ExecStart=/usr/sbin/text-2-json --port=53

[Install]
WantedBy=multi-user.target
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'
dotnet_diagnostic.CA1513.severity = none # Use 'ObjectDisposedException.ThrowIf' instead of explicitly throwing a new exception instance
dotnet dev-certs https --trust
set DOTNET_CLI_TELEMETRY_OPTOUT=1
setx DOTNET_CLI_TELEMETRY_OPTOUT 1
dotnet user-secrets list
cat ./input.json | dotnet user-secrets set
// 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 (...) {
        ...
    }
}
// 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"
    }
}
# 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)
dotnet_diagnostic.IDE0051.severity = error # Private member '' is unused [, ]
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
dotnet_diagnostic.CA1861.severity = none # CA1861: Prefer 'static readonly' fields over constant array arguments
dotnet_diagnostic.JSON002.severity = warning # JSON002: Probable JSON string detected
dotnet_diagnostic.IDE0230.severity = warning # IDE0230: Use UTF-8 string literal
# 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
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
mkdir -p ~/.microsoft/usersecrets/cc24ad7a-1d95-4c47-a3ea-0d8475ab06da
nano ~/.microsoft/usersecrets/cc24ad7a-1d95-4c47-a3ea-0d8475ab06da/secrets.json
dotnet nuget why Map/Map.csproj System.Private.Uri
# 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
#### .NET Coding Conventions ####

# Organize usings
dotnet_separate_import_directive_groups = true
dotnet_sort_system_directives_first = true