GithubHelp home page GithubHelp logo

Comments (2)

AArnott avatar AArnott commented on August 31, 2024

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.

from immutableobjectgraph.

dzmitry-lahoda avatar dzmitry-lahoda commented on August 31, 2024

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);

from immutableobjectgraph.

Related Issues (20)

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.