-
Notifications
You must be signed in to change notification settings - Fork 32
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
Document if capable generating readonly struct #114
Labels
Comments
I'm not sure what you're proposing or asking for here. So you know, this project generates new code to complement the code you've written using partial types. We can't change the code the user already wrote in this model. |
I meant if there is any logic in project to work with structs? But evident that it is not relevant here. Sorry. I doing some weird stuff at runtime dotnet/csharplang#1620 (comment) and public readonly struct reflect
{
private class taga : Attribute {} [taga]
public readonly long a;
private class tagb : Attribute {} [tagb]
public readonly float b;
private class tagc : Attribute {} [tagc]
public readonly double c;
private class tagd : Attribute {} [tagd]
public readonly decimal d;
private class tage : Attribute {} [tage]
public readonly BigInteger e;
// this will fail on during type init if there is no taga or taga marked wrong type as part of static init
public reflect UpdateA(long zz) => UnsafeToolsTests.Update<reflect, reflect.taga, long>(in this, zz);
}
private static class Change<TType,TTag, TValue>
where TType:unmanaged
where TTag: Attribute
{
public static int offset;
static Change()
{
// VALIDATE that filed tagged by tag is TValue
// Change<TType>.Validate() to validate that TType has all fields tagged.
// TODO: find ofsett of filed onto tag for ZERO COST GENERIC SUTCT ACCESS later
offset = 42;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TType Update<TType, TTag, TValue>(in TType v, in TValue t)
where TType:unmanaged
where TTag: Attribute
{
var attr = Change<TType, TTag, TValue>.offset;
var x = new TType();
throw new NotImplementedException("Unsafe.Add v -> Unsafe.Copy t into x from v");
return x;
}
[Fact]
public void Test()
{
reflect rrrr = default;
reflect rrrru = rrrr.UpdateA(123); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given:
Generate:
See Write safe and efficient C# code
Generate extension via System.Runtime.CompilerServices.Unsafe
For inspiration:
https://gitlab.com/dzmitry-lahoda/learning/blob/master/design/dod-ecs/Dod.Ecs/Ecs.cs
dotnet/csharplang#186
For:
Generate:
May some other fun things you already do, but struct oriented.
The text was updated successfully, but these errors were encountered: