philsa / polymorphicstructs Goto Github PK
View Code? Open in Web Editor NEWLicense: The Unlicense
License: The Unlicense
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.
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;
}
}
public Example<int> Example<int>_0;
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.
namespace Playground.ExamplePoly {
[PolymorphicStruct]
public interface IPoly {
public void DoThing();
}
}
namespace Playground.ExamplePoly.Test {
public partial struct PolyC : IPoly {
public void DoThing() { }
}
}
In another IPoly struct, add the using namespace
of what ever namespace is nested. These are picked up by the source generator.
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.
namespace Playground.ExamplePoly {
[PolymorphicStruct]
public interface IPoly {
public void DoThing();
}
}
namespace Playground.ExamplePoly {
public class NestedExample {
public partial struct PolyB : IPoly {
public void DoThing() { }
}
}
}
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;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.