Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 160 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,21 +1,178 @@
root = true

############################################################
# Basic file-type formatting
############################################################

[*.{json,yaml,yml}]
indent_size = 2

[*.md]
indent_size = 2

[*.{resx,ruleset,stylecop,xml,xsd,xsl}]
indent_size = 2

[*.{props,targets,config,nuspec}]
indent_size = 2

[*.tsv]
indent_style = tab

############################################################
# Standard formatting for C# and project files
############################################################

[*.{cs,csproj}]
indent_style = space
indent_size = 4
charset = utf-8
end_of_line = crlf
insert_final_newline = true

############################################################
# C# / .NET defaults - consolidated for clarity
############################################################

[*.cs]

# Set severity for all analyzers that are enabled by default (https://docs.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2022#set-rule-severity-of-multiple-analyzer-rules-at-once-in-an-editorconfig-file)
dotnet_analyzer_diagnostic.category-roslynator.severity = default|none|silent|suggestion|warning|error

# Enable/disable all analyzers by default
# NOTE: This option can be used only in .roslynatorconfig file
roslynator_analyzers.enabled_by_default = true #|false
roslynator_analyzers.enabled_by_default = true

# Set severity for a specific analyzer
# dotnet_diagnostic.<ANALYZER_ID>.severity = default|none|silent|suggestion|warning|error

# Enable/disable all refactorings
roslynator_refactorings.enabled = true #|false
roslynator_refactorings.enabled = true

# Enable/disable specific refactoring
# roslynator_refactoring.<REFACTORING_NAME>.enabled = true|false

# Enable/disable all compiler diagnostic fixes
roslynator_compiler_diagnostic_fixes.enabled = true #|false
roslynator_compiler_diagnostic_fixes.enabled = true

# Enable/disable specific compiler diagnostic fix
# roslynator_compiler_diagnostic_fix.<COMPILER_DIAGNOSTIC_ID>.enabled = true|false

# Sort using directives with System.* first
dotnet_sort_system_directives_first = true

# Default analyzer severity for most rules: suggestion (non-breaking for local dev)
dotnet_analyzer_diagnostic.severity = suggestion

# categories: sensible defaults for repository quality
# Style: formatting and stylistic suggestions
dotnet_analyzer_diagnostic.category-Style.severity = warning

# Performance: high-value performance rules treated as errors (e.g. hot-path logging)
dotnet_analyzer_diagnostic.category-Performance.severity = error

# Naming: recommendations; keep as suggestions to avoid developer friction
dotnet_analyzer_diagnostic.category-Naming.severity = suggestion

# Maintainability: suggestions for cleaner, maintainable code
dotnet_analyzer_diagnostic.category-Maintainability.severity = suggestion

# Interoperability: warn about platform/interop issues
dotnet_analyzer_diagnostic.category-Interoperability.severity = warning

# Design: API design and usage guidance
dotnet_analyzer_diagnostic.category-Design.severity = warning

# Documentation: XML/docs guidance as suggestions
dotnet_analyzer_diagnostic.category-Documentation.severity = suggestion

# Globalization: treat important globalization issues as errors (e.g. culture-sensitive formatting)
dotnet_analyzer_diagnostic.category-Globalization.severity = error

# Reliability: lifecycle/dispose and other reliability concerns - warn by default
dotnet_analyzer_diagnostic.category-Reliability.severity = warning

# Security: escalate security findings to errors
dotnet_analyzer_diagnostic.category-Security.severity = error

# Usage: general API usage guidance
dotnet_analyzer_diagnostic.category-Usage.severity = warning

# Modern C# style preferences (good defaults for .NET 10)
csharp_style_namespace_declarations = file_scoped
csharp_style_implicit_object_creation = true
csharp_style_target_typed_new_expression = true
csharp_style_pattern_matching_over_is_with_cast_check = true
csharp_style_prefer_not_pattern = true

csharp_style_pattern_matching_over_as_with_null_check = true
csharp_style_inlined_variable_declaration = true
csharp_style_throw_expression = true
csharp_style_prefer_switch_expression = true
csharp_prefer_simple_using_statement = true
csharp_style_prefer_pattern_matching = true
dotnet_style_operator_placement_when_wrapping = end_of_line

# # Prefer pattern-matching null checks (`is null` / `is not null`) over `== null` or ReferenceEquals
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
dotnet_diagnostic.IDE0041.severity = warning
# Also enable related null-check simplification rules
dotnet_diagnostic.IDE0029.severity = warning
dotnet_diagnostic.IDE0030.severity = warning
dotnet_diagnostic.IDE0270.severity = warning
dotnet_diagnostic.IDE0019.severity = warning

# Prefer var when the type is apparent (modern and concise)
# how does this work with IDE0007?
# var and explicit typing preferences
# csharp_style_var_for_built_in_types = false:none
# csharp_style_var_when_type_is_apparent = true:suggestion
# csharp_style_var_elsewhere = false:suggestion
csharp_style_var_when_type_is_apparent = true

# # Expression-bodied members where concise
csharp_style_expression_bodied_methods = when_on_single_line
csharp_style_expression_bodied_properties = when_on_single_line

# # Naming conventions (kept as suggestions)
# dotnet_naming_rule.private_fields_should_be_camel_case.severity = suggestion
# dotnet_naming_rule.private_fields_should_be_camel_case.symbols = private_fields
# dotnet_naming_rule.private_fields_should_be_camel_case.style = camel_case_underscore
# dotnet_naming_symbols.private_fields.applicable_kinds = field
# dotnet_naming_symbols.private_fields.applicable_accessibilities = private
# dotnet_naming_style.camel_case_underscore.capitalization = camel_case
# dotnet_naming_style.camel_case_underscore.required_prefix = _
# csharp_style_unused_value_expression_statement_preference = discard_variable


# Helpful IDE rules as suggestions so dotnet-format can apply fixes
dotnet_diagnostic.IDE0005.severity = suggestion # Remove unnecessary usings
dotnet_diagnostic.IDE0059.severity = suggestion # Unused assignment
dotnet_diagnostic.IDE0051.severity = suggestion # Unused private members
dotnet_diagnostic.IDE0060.severity = suggestion # Unused parameters
dotnet_diagnostic.IDE0058.severity = suggestion # Expression value is never used
dotnet_diagnostic.IDE0130.severity = suggestion # Use 'new' expression where possible (target-typed new)
csharp_style_unused_value_expression_statement_preference = discard_variable
# Nullable reference types - enabled as suggestions; project opt-in controls runtime enforcement
nullable = enable
csharp_style_prefer_primary_constructors = false

# Formatting / newline preferences
# prefer Stroustrup
csharp_new_line_before_open_brace = false
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_prefer_braces = when_multiline
# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current



# Using directive placement
csharp_using_directive_placement = outside_namespace
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
src/*/bin/*
src/*/obj/*
src/.vs/*
**/bin/**
**/obj/**
**/.vs/**
output/*
output
.vs/*
!assets/*.png
test_alc.ps1
testimages.ps1
testimages/*
testdata/*
refdocs/*
*.md
!docs/en-US/*.md
!README.md
126 changes: 126 additions & 0 deletions Sixel.build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#! /usr/bin/pwsh
#Requires -Version 7.4 -Module InvokeBuild
param(
[string]$Configuration = 'Release',
[switch]$SkipHelp,
[switch]$SkipTests
)
Write-Host "$($PSBoundParameters.GetEnumerator())" -ForegroundColor Cyan

$modulename = [System.IO.Path]::GetFileName($PSCommandPath) -replace '\.build\.ps1$'

$script:folders = @{
ModuleName = $modulename
ProjectRoot = $PSScriptRoot
SourcePath = Join-Path $PSScriptRoot 'src' $modulename
OutputPath = Join-Path $PSScriptRoot 'output'
DestinationPath = Join-Path $PSScriptRoot 'output' 'lib'
ModuleSourcePath = Join-Path $PSScriptRoot 'module'
DocsPath = Join-Path $PSScriptRoot 'docs' 'en-US'
TestPath = Join-Path $PSScriptRoot 'tests'
CsprojPath = Join-Path $PSScriptRoot 'src' $modulename "$modulename.csproj"
}

task Reset {
if (Test-Path $folders.OutputPath) {
Remove-Item -Path $folders.OutputPath -Recurse -Force -ErrorAction 'Ignore'
}
New-Item -Path $folders.OutputPath -ItemType Directory -Force | Out-Null
}

task Build {
if (-not (Test-Path $folders.CsprojPath)) {
Write-Warning 'C# project not found, skipping Build'
return
}
$ModuleFile = Import-PowerShellDataFile -Path (Join-Path $script:folders.ProjectRoot 'Module' "$($script:folders.ModuleName).psd1")
[xml]$csproj = Get-Content -Path $folders.CsprojPath -Raw
$dotnetArgs += '-p:Version={0}' -f $ModuleFile.ModuleVersion.ToString()
$frameworks = $csproj.
SelectNodes('//TargetFramework | //TargetFrameworks').
'#text'.
Split(';', [StringSplitOptions]::RemoveEmptyEntries)

$dotnetArgs = @(
'publish'
$folders.CsprojPath
'--configuration', $Configuration
'--nologo'
'--verbosity', 'minimal'
)
Comment thread
trackd marked this conversation as resolved.
foreach ($fwork in $frameworks) {
exec { dotnet @dotnetArgs --framework $fwork --output (Join-Path $folders.DestinationPath $fwork) }
}
}

task ModuleFiles {
if (Test-Path $folders.ModuleSourcePath) {
Get-ChildItem -Path $folders.ModuleSourcePath -File | Copy-Item -Destination $folders.OutputPath -Force
}
else {
Write-Warning "Module directory not found at: $($folders.ModuleSourcePath)"
}
}

task GenerateHelp -if (-not $SkipHelp) {
if (-not (Test-Path $folders.DocsPath)) {
Write-Warning "Documentation path not found at: $($folders.DocsPath)"
return
}
if (-not (Get-Module -ListAvailable -Name Microsoft.PowerShell.PlatyPS)) {
Write-Host ' Installing Microsoft.PowerShell.PlatyPS...' -ForegroundColor Yellow
Install-Module -Name Microsoft.PowerShell.PlatyPS -Scope CurrentUser -Force -AllowClobber
}

Import-Module Microsoft.PowerShell.PlatyPS -ErrorAction Stop

$modulePath = Join-Path $folders.OutputPath ($folders.ModuleName + '.psd1')
if (-not (Test-Path $modulePath)) {
Write-Warning "Module manifest not found at: $modulePath. Skipping help generation."
return
}

Import-Module $modulePath -Force

$helpOutputPath = Join-Path $folders.OutputPath 'en-US'
New-Item -Path $helpOutputPath -ItemType Directory -Force | Out-Null

$allCommandHelp = Get-ChildItem -Path $folders.DocsPath -Filter '*.md' -Recurse -File |
Where-Object { $_.Name -ne "$($folders.ModuleName).md" } |
Import-MarkdownCommandHelp

if ($allCommandHelp.Count -gt 0) {
$tempOutputPath = Join-Path $helpOutputPath 'temp'
Export-MamlCommandHelp -CommandHelp $allCommandHelp -OutputFolder $tempOutputPath -Force | Out-Null

$generatedFile = Get-ChildItem -Path $tempOutputPath -Filter '*.xml' -Recurse -File | Select-Object -First 1
if ($generatedFile) {
Move-Item -Path $generatedFile.FullName -Destination $helpOutputPath -Force
}
Remove-Item -Path $tempOutputPath -Recurse -Force -ErrorAction SilentlyContinue
}
}

task Test -if (-not $SkipTests) {
if (-not (Test-Path $folders.TestPath)) {
Write-Warning "Test directory not found at: $($folders.TestPath)"
return
}
$pesterConfig = New-PesterConfiguration
# $pesterConfig.Output.Verbosity = 'Detailed'
$pesterConfig.Run.Path = $folders.TestPath
$pesterConfig.Run.Throw = $true
$pesterConfig.Debug.WriteDebugMessages = $false
Invoke-Pester -Configuration $pesterConfig
}

task CleanAfter {
if ($script:folders.DestinationPath -and (Test-Path $script:folders.DestinationPath)) {
Get-ChildItem -Path $script:folders.DestinationPath -File -Recurse |
Where-Object { $_.Extension -in @('.pdb', '.json') } |
Remove-Item -Force -ErrorAction Ignore
}
}


task All -Jobs Reset, Build, ModuleFiles, GenerateHelp, CleanAfter, Test
37 changes: 0 additions & 37 deletions Sixel.sln

This file was deleted.

6 changes: 6 additions & 0 deletions Sixel.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Solution>
<Folder Name="/src/">
<Project Path="src/Sixel.Shared/Sixel.Shared.csproj" />
<Project Path="src/Sixel/Sixel.csproj" />
</Folder>
</Solution>
Loading
Loading