Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figgle Generator not creating strings. #19

Closed
HowardShank opened this issue Jan 16, 2024 · 7 comments
Closed

Figgle Generator not creating strings. #19

HowardShank opened this issue Jan 16, 2024 · 7 comments
Labels

Comments

@HowardShank
Copy link

Hello,
I'm trying to use the generator.

Visual Studio 2022 v17.8.4
.Net 8
Project type: library
Pacakge: Figgle.Generator v0.5.1

My class code:

Filename: StartupBanners.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Figgle;

namespace MyProject.Lib.Common
{
    [GenerateFiggleTextAttribute("DevelopmentString", "standard", "Development")]
    public partial class StartupBanners
    {
    }
}

When I compile the app I see no partial class code generation.
I've tried the following.

Without a StartupBanners.partial`1.cs file

With a StartupBanners.partial`1.cs file

Am I missing something?

Thank you,
Howard Shank

@drewnoakes
Copy link
Owner

Does your StartupBanners class include a Development property?

To see generated files you need to set the EmitCompilerGeneratedFiles property in your project:

<PropertyGroup>
    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>

This will write a file to a location such as obj/Debug/net8.0/generated/MyProject.Lib.Common.

Note that source generators don't write this file by default for performance reasons. The disk IO is avoidable.

@HowardShank
Copy link
Author

Thanks for the quick response.

I do not have that in setting configured. I'll test that tomorrow.

So if the string is generated there, how is it usable as a reference in my source elsewhere? Or is the string just something that you go copy and put in your code where you need it?

@drewnoakes
Copy link
Owner

With the source generator, the output string is computed at compile time, rather than at run time, so it's faster when your program runs (nothing to compute) and you don't need to ship Figgle binaries (which include large font files, embedded).

So your program could resemble this:

[GenerateFiggleTextAttribute("DevelopmentString", "standard", "Development")]
public partial class StartupBanners
{
}

public static class Greeter
{
    public static void PrintDevelopment() => Console.WriteLine(StartupBanners.DevelopmentString);
}

@HowardShank
Copy link
Author

Thank you for your help with this. I appreciate it.

How difficult is it to remove all the fonts except one from the runtime package?

@drewnoakes
Copy link
Owner

drewnoakes commented Jan 17, 2024

It would require some refactoring of the packages I think. You can easily parse a single figlet file using the APIs, but today the core fonts are embedded for convenience.

See #12.

@HowardShank
Copy link
Author

Do you mind if I pull the source and give it a shot?

@drewnoakes
Copy link
Owner

You're welcome to play with it! But if you're hoping to land a change in this repo, I recommend sharing a proposal as to how that might work before submitting a PR. That could save you a bunch of time.

Let's continue the discussion in #12. Looks like the original issue here has been addressed so I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants