Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Upgrade .netstandard to 2.0 #103

Merged
merged 4 commits into from
Mar 27, 2019
Merged

Upgrade .netstandard to 2.0 #103

merged 4 commits into from
Mar 27, 2019

Conversation

shargon
Copy link
Member

@shargon shargon commented Mar 27, 2019

Currently we have this framework:

<TargetFrameworks>netstandard1.6;net461</TargetFrameworks>

In order to unify the projects i think that we should define it as:

<TargetFramework>netcoreapp2.2</TargetFramework>

Currently we have this framework:

 `<TargetFrameworks>netstandard1.6;net461</TargetFrameworks>`

In order to unify the projects i think that we should define it as:

`<TargetFramework>netcoreapp2.2</TargetFramework>`
@shargon shargon requested a review from erikzhang March 27, 2019 15:55
@erikzhang
Copy link
Member

We need to keep it as .NET Standard project for compatibility.

@shargon
Copy link
Member Author

shargon commented Mar 27, 2019

I want to use some reflection methods and i have problems

image

I think that we can use Attributes for make cleaner the new PR

image

private static OperandBaseAttribute[] operandCache = new OperandBaseAttribute[byte.MaxValue];

        static Instruction()
        {
            foreach (OpCode op in Enum.GetValues(typeof(OpCode)))
            {
                operandCache[(byte)op] = op.GetAttributeOfType<OperandBaseAttribute>();
            }
        }

internal Instruction(byte[] script, int ip)
        {
            this.OpCode = (OpCode)script[ip++];
            this.Size = 1;

            var parser = operandCache[(byte)this.OpCode];

            if (parser != null)
            {
                Operand = parser.ReadOperand(script, ref ip, ref this.Size);
            }
            else
            {
                Operand = new byte[0];
            }
        }

@erikzhang
Copy link
Member

You can upgrade it to .NET Standard 2.0

@erikzhang
Copy link
Member

Also, I don't think reflection will be faster than switch.

@shargon
Copy link
Member Author

shargon commented Mar 27, 2019

reflection is slower, but should be cached in a static way

@shargon shargon changed the title Change project to: dotnet core Upgrade .netstandard to 2.0 Mar 27, 2019
@erikzhang
Copy link
Member

The difficulty of using Attributes on OpCode is the values between PUSHBYTES1 and PUSHBYTES75.

@erikzhang erikzhang changed the base branch from master to instruction March 27, 2019 18:18
@shargon
Copy link
Member Author

shargon commented Mar 27, 2019

I added these enum values :P, do you like it? xD

@erikzhang
Copy link
Member

@shargon I studied it and found no good way to use Attributes to cache size information. The main problem is the values between PUSHBYTES1 and PUSHBYTES75. If you have any good ways, commit them directly to this PR.

@erikzhang
Copy link
Member

I added these enum values :P, do you like it? xD

No, this is too cumbersome. . .

@shargon shargon merged commit 8159c2a into instruction Mar 27, 2019
@shargon shargon deleted the unify-projects branch March 27, 2019 19:45
@erikzhang
Copy link
Member

Wait, if you didn't use reflection, there is no need to upgrade .NET Standard to 2.0

erikzhang added a commit that referenced this pull request Mar 28, 2019
@shargon
Copy link
Member Author

shargon commented Mar 28, 2019

Ok, i will made a PR with this and reflection, and we can evaluate if is better or not

@erikzhang
Copy link
Member

erikzhang commented Mar 28, 2019

Can you approve #102, and make a new PR with reflection?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants