Skip to content

Commit

Permalink
Updated source generator to allow ignoring autodependencies (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-goldman authored Nov 4, 2024
1 parent 81674da commit e8c2edb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Maui.Plugins.PageResolver.Attributes;

[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class NoAutoDependenciesAttribute : Attribute { }
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ public void Execute(GeneratorExecutionContext context)
throw new Exception("MauiProgram not found.");
}

bool hasNoAutoDependenciesAttribute = mauiProgram.GetAttributes()
.Any(ad => ad.AttributeClass.ToDisplayString() == "Maui.Plugins.PageResolver.Attributes.NoAutoDependenciesAttribute");

if (hasNoAutoDependenciesAttribute)
{
Log.WriteLine("NoAutoDependenciesAttribute found, skipping.");
return;
}

Log.WriteLine($"Found main method: {mauiProgram.Name}");

StringBuilder sourceBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageIcon>gfg.png</PackageIcon>
<PackageIconUrl />
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>2.5.1</Version>
<Version>2.5.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit e8c2edb

Please sign in to comment.