Code Monkey home page Code Monkey logo

polymorphicstructs's People

Contributors

philsa avatar xseagullx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

polymorphicstructs's Issues

Generic Fields Break Generated Naming Scheme

Problem:

PolymorphicStructs that are have generics used as a field, can't compile due to the name generated. Common use case will likely be BlobAssetReferences, but for sake of example, I quickly created a generic struct below. Breaks compilation.

Example

namespace Playground.ExamplePoly {
    [PolymorphicStruct]
    public interface IPoly {
        public void DoThing();
    }
}
namespace Playground.ExamplePoly {
    public partial struct PolyA : IPoly {
        public Example<int> Test;
        public void DoThing() {
        }
    }

    public struct Example<T> where T : unmanaged {
        public T Value;
    }
}

Current Result

public Example<int> Example<int>_0;

Different Namespaces are not Generated

Problem:

PolymorphicStructs that are created in a different namespace than the interface are not generated in their using statements of the generated struct file, breaking compilation.

Example

namespace Playground.ExamplePoly {
    [PolymorphicStruct]
    public interface IPoly {
        public void DoThing();
    }
}
namespace Playground.ExamplePoly.Test {
    public partial struct PolyC : IPoly {
        public void DoThing() { }
    }
}

Current Temporary Workaround

In another IPoly struct, add the using namespace of what ever namespace is nested. These are picked up by the source generator.

Nested Structs lose `partial` keyword

Problem:

PolymorphicStructs that are created in a nested structs, according to the IDE (Rider), don't have a partial sibling related to it.. This breaks compilation.

Example

namespace Playground.ExamplePoly {
    [PolymorphicStruct]
    public interface IPoly {
        public void DoThing();
    }
}
namespace Playground.ExamplePoly {
    public class NestedExample {
        public partial struct PolyB : IPoly {
            public void DoThing() { }
        }
    }
}

Potential Related Issues

Static or type definition using statements are lost on source generation. Examples below of what is written vs what is generated.

using static Playground.ExamplePoly.NestedExample.PolyB; //This example is not using both at the same time, but the result is the same.
using PolyB = Playground.ExamplePoly.NestedExample.PolyB;

Result:

using Playground.ExamplePoly.NestedExample.PolyB;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.