diff --git a/devtools/install-templates.ps1 b/devtools/install-templates.ps1 index 255f8c2..458ed1e 100644 --- a/devtools/install-templates.ps1 +++ b/devtools/install-templates.ps1 @@ -186,6 +186,26 @@ function Install-FromPackage { $files = @(Get-ChildItem -Path $nupkgBase -Filter '*.nupkg' -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Name -notmatch '\.(symbols|snupkg)\.nupkg$' }) + if ($files.Count -eq 0) { + Write-Host '' + Write-Host ' No se encontraron paquetes. Ejecutando dotnet pack...' -ForegroundColor DarkGray + + $csproj = Join-Path $TemplatesFolder 'ProjectTemplates.csproj' + & dotnet pack $csproj --configuration Release --output $nupkgBase + + if ($LASTEXITCODE -ne 0) { + Write-Host '' + Write-Host ' [ERROR] Fallo al empaquetar.' -ForegroundColor Red + Wait-BackToMenu + return + } + + Write-Host ' [OK] Paquete generado.' -ForegroundColor Green + + $files = @(Get-ChildItem -Path $nupkgBase -Filter '*.nupkg' -Recurse -ErrorAction SilentlyContinue | + Where-Object { $_.Name -notmatch '\.(symbols|snupkg)\.nupkg$' }) + } + $pkg = $null if ($files.Count -eq 0) { diff --git a/src/EasyWindowsApplication.Generators/EasyBehaviorGenerator.cs b/src/EasyWindowsApplication.Generators/EasyBehaviorGenerator.cs index b1f4fa8..ec43c69 100644 --- a/src/EasyWindowsApplication.Generators/EasyBehaviorGenerator.cs +++ b/src/EasyWindowsApplication.Generators/EasyBehaviorGenerator.cs @@ -1,4 +1,4 @@ -#nullable disable + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -128,7 +128,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) if (!enclosing.IsDefaultOrEmpty && enclosing[0] is not null) { - var enclosingInfo = enclosing[0]; + var enclosingInfo = enclosing[0]!; var ns = enclosingInfo.Namespace; var className = enclosingInfo.ClassName; @@ -304,7 +304,7 @@ private static bool IsViewControlCandidate(SyntaxNode node) return true; } - private static Location ExtractControlLocation(GeneratorSyntaxContext context) + private static Location? ExtractControlLocation(GeneratorSyntaxContext context) { var inv = (InvocationExpressionSyntax)context.Node; if (inv.Expression is not MemberAccessExpressionSyntax ma) @@ -333,7 +333,7 @@ private static Location ExtractControlLocation(GeneratorSyntaxContext context) return null; } - private static EnclosingTypeInfo ExtractEnclosingType(GeneratorSyntaxContext context) + private static EnclosingTypeInfo? ExtractEnclosingType(GeneratorSyntaxContext context) { var current = context.Node.Parent; while (current is not null) @@ -380,20 +380,12 @@ private static string SanitizeName(string name) return sb.ToString(); } - private readonly struct NamedInfo + private readonly struct NamedInfo(string name, string typeSymbol, bool isWindowType, Location location) { - public readonly string Name; - public readonly string TypeSymbol; - public readonly bool IsWindowType; - public readonly Location Location; - - public NamedInfo(string name, string typeSymbol, bool isWindowType, Location location) - { - Name = name; - TypeSymbol = typeSymbol; - IsWindowType = isWindowType; - Location = location; - } + public readonly string Name = name; + public readonly string TypeSymbol = typeSymbol; + public readonly bool IsWindowType = isWindowType; + public readonly Location Location = location; public override bool Equals(object obj) => obj is NamedInfo other && Name == other.Name && TypeSymbol == other.TypeSymbol && IsWindowType == other.IsWindowType; @@ -402,10 +394,9 @@ public override int GetHashCode() => (Name?.GetHashCode() ?? 0) ^ (TypeSymbol?.GetHashCode() ?? 0) ^ IsWindowType.GetHashCode(); } - private sealed class EnclosingTypeInfo + private sealed class EnclosingTypeInfo(string ns, string className) { - public readonly string Namespace; - public readonly string ClassName; - public EnclosingTypeInfo(string ns, string className) { Namespace = ns; ClassName = className; } + public readonly string Namespace = ns; + public readonly string ClassName = className; } } diff --git a/src/EasyWindowsApplication.Generators/EasyWindowsApplication.Generators.csproj b/src/EasyWindowsApplication.Generators/EasyWindowsApplication.Generators.csproj index dafac34..5fabcb6 100644 --- a/src/EasyWindowsApplication.Generators/EasyWindowsApplication.Generators.csproj +++ b/src/EasyWindowsApplication.Generators/EasyWindowsApplication.Generators.csproj @@ -2,14 +2,16 @@ netstandard2.0 - disable + enable enable + latest - true - $(NoWarn);RS2008 + true - true + true false + true + true True EasyWindowsApplication.Generators @@ -28,23 +30,25 @@ - + + True \ - + True \ - - + + - + + diff --git a/src/EasyWindowsApplication.Generators/Properties/AnalyzerReleases.Shipped.md b/src/EasyWindowsApplication.Generators/Properties/AnalyzerReleases.Shipped.md new file mode 100644 index 0000000..e69de29 diff --git a/src/EasyWindowsApplication.Generators/Properties/AnalyzerReleases.Unshipped.md b/src/EasyWindowsApplication.Generators/Properties/AnalyzerReleases.Unshipped.md new file mode 100644 index 0000000..5db0b9f --- /dev/null +++ b/src/EasyWindowsApplication.Generators/Properties/AnalyzerReleases.Unshipped.md @@ -0,0 +1,6 @@ +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|-------------------- +EAWIN001 | EasyWindowsApplication | Error | +EAWIN002 | EasyWindowsApplication | Error | diff --git a/src/EasyWindowsApplication.slnx b/src/EasyWindowsApplication.slnx index c661db4..d759bce 100644 --- a/src/EasyWindowsApplication.slnx +++ b/src/EasyWindowsApplication.slnx @@ -2,6 +2,7 @@ + diff --git a/src/EasyWindowsApplication/EasyWindowsApplication.csproj b/src/EasyWindowsApplication/EasyWindowsApplication.csproj index c7abf5e..8f46634 100644 --- a/src/EasyWindowsApplication/EasyWindowsApplication.csproj +++ b/src/EasyWindowsApplication/EasyWindowsApplication.csproj @@ -31,13 +31,13 @@ - + True \ - - True - \ + + True + \ diff --git a/src/ProjectTemplates/ProjectTemplates.csproj b/src/ProjectTemplates/ProjectTemplates.csproj index e6490f2..e008e7a 100644 --- a/src/ProjectTemplates/ProjectTemplates.csproj +++ b/src/ProjectTemplates/ProjectTemplates.csproj @@ -1,28 +1,45 @@ - - netstandard2.0 - true - false - content - Template - EasyWindowsApplication.Templates - RandAMediaLabGroup.EasyWindowsApplication.Templates - 0.0.0 - cl2raul66 - RandAMediaLabGroup - Plantillas dotnet new (easywinapp / simpleeasywinapp) para el framework EasyWindowsApplication - template; win32; windows-application; easy-windows-application; easywinapp; simpleeasywinapp - MIT - True - https://github.com/cl2raul66/EasyWindowsApplication - https://github.com/cl2raul66/EasyWindowsApplication - + + netstandard2.0 + true + false + content + Template + EasyWindowsApplication.Templates - - - - - + MIT License + RandAMediaLabGroup.EasyWindowsApplication.Templates + 0.0.0 + cl2raul66 + RandAMediaLabGroup + Plantillas dotnet new (easywinapp / simpleeasywinapp) para el framework EasyWindowsApplication + template; win32; windows-application; easy-windows-application; easywinapp; simpleeasywinapp + True + https://github.com/cl2raul66/EasyWindowsApplication + https://github.com/cl2raul66/EasyWindowsApplication + logo_template.png + True + README.md + MIT + True + + + + + + + + + + + True + \ + + + True + \ + + \ No newline at end of file