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
20 changes: 20 additions & 0 deletions devtools/install-templates.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
33 changes: 12 additions & 21 deletions src/EasyWindowsApplication.Generators/EasyBehaviorGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable disable


using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<LangVersion>latest</LangVersion>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<NoWarn>$(NoWarn);RS2008</NoWarn>

<IsRoslynComponent>true</IsRoslynComponent>
<DevelopmentDependency>true</DevelopmentDependency>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<DevelopmentDependency>true</DevelopmentDependency>

<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>EasyWindowsApplication.Generators</Title>
Expand All @@ -28,23 +30,25 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md"> <!-- (B) -->
<None Include="$(TargetPath)" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\rsc\Images\logo_template.png"> <!-- (B) -->
<None Include="..\..\rsc\Images\logo_template.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="*" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="*" PrivateAssets="all" />
<AdditionalFiles Include="Properties\AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="Properties\AnalyzerReleases.Unshipped.md" />
</ItemGroup>

<ItemGroup>
<None Include="$(TargetPath)" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="*" PrivateAssets="all"/>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="*" PrivateAssets="all" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|--------------------
EAWIN001 | EasyWindowsApplication | Error |
EAWIN002 | EasyWindowsApplication | Error |
1 change: 1 addition & 0 deletions src/EasyWindowsApplication.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project Path="EasyWindowsApplication.Generators/EasyWindowsApplication.Generators.csproj" />
<Project Path="EasyWindowsApplication/EasyWindowsApplication.csproj" />
<Project Path="ProjectTemplates/EasyWinApp/EasyWinApp.csproj" />
<Project Path="ProjectTemplates/ProjectTemplates.csproj" />
<Project Path="ProjectTemplates/SimpleEasyWinApp/SimpleEasyWinApp.csproj" />
<Project Path="Sample/Sample.csproj" Id="0cbd3060-e5d2-464f-9d8a-b7a8795bce6c" />
</Solution>
8 changes: 4 additions & 4 deletions src/EasyWindowsApplication/EasyWindowsApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md"> <!-- (B) -->
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\rsc\Images\logo_template.png"> <!-- (B) -->
<Pack>True</Pack>
<PackagePath>\</PackagePath>
<None Include="..\..\rsc\Images\logo_template.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

Expand Down
63 changes: 40 additions & 23 deletions src/ProjectTemplates/ProjectTemplates.csproj
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
<PackageType>Template</PackageType>
<Title>EasyWindowsApplication.Templates</Title>
<PackageId>RandAMediaLabGroup.EasyWindowsApplication.Templates</PackageId>
<Version>0.0.0</Version>
<Authors>cl2raul66</Authors>
<Company>RandAMediaLabGroup</Company>
<Description>Plantillas dotnet new (easywinapp / simpleeasywinapp) para el framework EasyWindowsApplication</Description>
<PackageTags>template; win32; windows-application; easy-windows-application; easywinapp; simpleeasywinapp</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/cl2raul66/EasyWindowsApplication</RepositoryUrl>
<PackageProjectUrl>https://github.com/cl2raul66/EasyWindowsApplication</PackageProjectUrl>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
<PackageType>Template</PackageType>
<Title>EasyWindowsApplication.Templates</Title>

<ItemGroup>
<Compile Remove="**\*" />
<Content Include="EasyWinApp\**" Exclude="EasyWinApp\bin\**;EasyWinApp\obj\**;EasyWinApp\.vs\**" />
<Content Include="SimpleEasyWinApp\**" Exclude="SimpleEasyWinApp\bin\**;SimpleEasyWinApp\obj\**;SimpleEasyWinApp\.vs\**" />
</ItemGroup>
<Copyright>MIT License</Copyright>
<PackageId>RandAMediaLabGroup.EasyWindowsApplication.Templates</PackageId>
<Version>0.0.0</Version>
<Authors>cl2raul66</Authors>
<Company>RandAMediaLabGroup</Company>
<Description>Plantillas dotnet new (easywinapp / simpleeasywinapp) para el framework EasyWindowsApplication</Description>
<PackageTags>template; win32; windows-application; easy-windows-application; easywinapp; simpleeasywinapp</PackageTags>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/cl2raul66/EasyWindowsApplication</RepositoryUrl>
<PackageProjectUrl>https://github.com/cl2raul66/EasyWindowsApplication</PackageProjectUrl>
<PackageIcon>logo_template.png</PackageIcon>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<SuppressDependenciesWhenPacking>True</SuppressDependenciesWhenPacking>
</PropertyGroup>

<ItemGroup>
<Compile Remove="**\*" />
<Content Include="EasyWinApp\**" Exclude="EasyWinApp\bin\**;EasyWinApp\obj\**;EasyWinApp\.vs\**" />
<Content Include="SimpleEasyWinApp\**" Exclude="SimpleEasyWinApp\bin\**;SimpleEasyWinApp\obj\**;SimpleEasyWinApp\.vs\**" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\..\rsc\Images\logo_template.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
Loading