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

Problems with Resources generator generated code #155

Closed
justinwritescode opened this issue Jan 6, 2023 · 0 comments · Fixed by #157 or #160
Closed

Problems with Resources generator generated code #155

justinwritescode opened this issue Jan 6, 2023 · 0 comments · Fixed by #157 or #160
Labels
bug Something isn't working

Comments

@justinwritescode
Copy link

Describe the Bug

  • Relative path names (e.g., "./") generate dots (".") as partial class names
  • Dashes in path names generate attempts at dashes in class names

Steps to Reproduce

Embed the file name "./swagger-ui/swagger-ui.css" in a .csproj file

This is the result:

partial class ThisAssembly
{
    public static partial class Resources
    {
        public static partial class . <-- this is bad {

        public static partial class swagger - <-- so is this

        ui {
        /// <summary>
        /// => @"./swagger-ui/swagger-ui.css"
        /// </summary>
        public static partial class swagger -

        ui {
        public static byte[] GetBytes() => EmbeddedResource.GetBytes(@"./swagger-ui/swagger-ui.css");
        public static Stream GetStream() => EmbeddedResource.GetStream(@"./swagger-ui/swagger-ui.css");
    }
} } } }

Expected Behavior

Expect the output to look like either this:

partial class ThisAssembly
{
    public static partial class Resources
    {
        public static partial class swaggerui {
        /// <summary>
        /// => @"./swagger-ui/swagger-ui.css"
        /// </summary>
        public static partial class swaggerui {
        public static byte[] GetBytes() => EmbeddedResource.GetBytes(@"./swagger-ui/swagger-ui.css");
        public static Stream GetStream() => EmbeddedResource.GetStream(@"./swagger-ui/swagger-ui.css");
    }
} }

Or this:

partial class ThisAssembly
{
    public static partial class Resources
    {
        public static partial class swagger_ui {
        /// <summary>
        /// => @"./swagger-ui/swagger-ui.css"
        /// </summary>
        public static partial class swagger_ui {
        public static byte[] GetBytes() => EmbeddedResource.GetBytes(@"./swagger-ui/swagger-ui.css");
        public static Stream GetStream() => EmbeddedResource.GetStream(@"./swagger-ui/swagger-ui.css");
    }
} }

Exception with Stack Trace

error CS0111: Type 'ThisAssembly.Resources.themes' already defines a member called 'GetBytes' with the same parameter types 

Which also brings up another potential issue, which I'll raise in a separate ticket

Version Info

1.1.1

Additional Info

Nope!

@justinwritescode justinwritescode added the bug Something isn't working label Jan 6, 2023
@kzu kzu closed this as completed in #157 Jan 10, 2023
kzu pushed a commit that referenced this issue Jan 10, 2023
* Improve collection of extensions

`HashSet<>` is not cacheable, so it will not be effective at reducing the number of calls to generator. This will reduce performance. Switching to `.Collect()`/`ImmutableArray` will allow the caching system to work as intended.

* Add support for files w/ different extensions; invalid filenames

Fixes #155 
Fixes #156
kzu added a commit that referenced this issue Jan 10, 2023
The existing santizing wasn't enough.

Fixes #155
kzu added a commit that referenced this issue Jan 10, 2023
The existing santizing wasn't enough.

Fixes #155
@devlooped devlooped locked and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
1 participant