Rai
MemoryMarshal.Cast on a struct with array of known fixed size
I'm wondering if there is some way to marshal a byte array into a struct that is known to be of fixed size, or has known length values via other fields:
Althought due to MarshalAs it should be known that it's up to 4 elements this wouldn't work due to the array being recognized as a pointer/reference type.
Is there a way to do this without having to enable unsafe and abuse the fixed keyword?
5 replies
SourceGenerator multiple steps (passing data from one to another)
Is there some way, possibly even documented way, to get let's say an attribute name in one SyntaxProvider Collection and do something with that in another one.
As of now I haven't found a way to make this work, as manually calling Collect and Select outside of RegisterSourceOutput results in the local variables being used as temp storage to transport these values between steps to have these values but only as long as they are inside the lambda scope of the Select method, the moment it's outside any change to local variables is lost.
Even attempts such as using static fields will not provide a working solution, nor playing around with passing the IncrementalValueProvider around to each and every step doesn't seem to be a possible solution.
Furthermore there doesn't seem to any documented examples of this when looking at the dotnet provided examples at: https://github.com/dotnet/roslyn-sdk/tree/main/samples/CSharp/SourceGenerators/SourceGeneratorSamples
e.g code along the lines of.:
If reasoning may be required:
I require to retrieve all attributes that inherit from a generic attribute in order to properly seperate if necessary the later on fetched classes in to their respective groups.
Furthermore these provided attributes contain necessary metadata, which are required for the generation of the necessary code.
13 replies