Code Monkey home page Code Monkey logo

Comments (9)

viruscamp avatar viruscamp commented on July 17, 2024 1
    public interface I0
    {
        string NameI0 { get => "I0.Name"; }
        string OverloadSuperMethod() => "I0.OverloadSuperMethod()";
        string SubPropertySuperMethod() => "I0.SubPropertySuperMethod()";
    }

    public interface I1 : I0
    {
        string Name { get; }
        string OverloadSuperMethod(int x) => $"I1.OverloadSuperMethod(int {x})";
        new string SubPropertySuperMethod => "I1.SubPropertySuperMethod";
    }

    [Fact]
    public void CallSuperPropertyFromInterface()
    {
        Assert.Equal(holder.I1.NameI0, _engine.Evaluate("holder.I1.NameI0"));
    }

    [Fact]
    public void CallOverloadSuperMethod()
    {
        Assert.Equal(holder.I1.OverloadSuperMethod(1), _engine.Evaluate("holder.I1.OverloadSuperMethod(1)"));
        Assert.Equal(holder.I1.OverloadSuperMethod(), _engine.Evaluate("holder.I1.OverloadSuperMethod()"));
    }

    [Fact]
    public void CallSubPropertySuperMethod()
    {
        Assert.Equal(holder.I1.SubPropertySuperMethod, _engine.Evaluate("holder.I1.SubPropertySuperMethod"));
        // Property and method cannot coexist
        Assert.Throws<Exception>(() => _engine.Evaluate("holder.I1.SubPropertySuperMethod()"));
    }

You PR pass CallOverloadSuperMethod but break CallSubPropertySuperMethod.

IMO, we'd better refactor TypeResolver , take care of the search order.
And fill property cache when loaded, remove property lazyload.

from jint.

hyzx86 avatar hyzx86 commented on July 17, 2024 1

@Genteure 回复完 我愣了一下。。。我以为浏览器开了翻译。。原来你发的就是中文🤣

from jint.

hyzx86 avatar hyzx86 commented on July 17, 2024

You PR pass CallOverloadSuperMethod but break CallSubPropertySuperMethod.

How is the holder instantiated in your code?

IMO, we'd better refactor TypeResolver , take care of the search order. And fill property cache when loaded, remove property lazyload.

Yes I agree, suggest refactoring TryFindMemberAccessor into replaceable logic ,Just like the MemberNameCreator and the MemberNameComparer 😁

from jint.

Genteure avatar Genteure commented on July 17, 2024

I searched around in https://github.com/dotnetcore/FreeSql on GitHub (so not in an IDE) and I can't seem to find an implementation of ISelect0. Can you tell me what's the concrete type of objSelect in your initial example code please?

from jint.

hyzx86 avatar hyzx86 commented on July 17, 2024

@Genteure Here is a unit test in FreeSql

SqliteSelectTest

In my project ,my method will retrun a type of ISelect<object>
like this:

        public ISelect<object> SelectTypedQuery(string typeName = default)
        {
            if (string.IsNullOrEmpty(typeName))
            {
                return FreeSql.Select<object>().AsType(typeof(ContentItemIndex));
            }

            var indexService = _serviceProvider.GetRequiredService<IDynamicIndexAppService>();
            var type = indexService.GetDynamicIndexType(typeName);
            if (type != null)
            {
                return FreeSql.Select<object>().AsType(type);
            }
            else
            {
                throw new Exception($"Type not found. : {typeName} ");
            }
        }

from jint.

Genteure avatar Genteure commented on July 17, 2024

@hyzx86 我是想问它的实际运行时的类型是什么,方便我确认一下现在的 unit test 是否能代表实际你遇到的问题。我对那个项目不熟悉,项目里面的抽象层又太多,我在 GitHub 上搜索代码找不到一个实现了 ISelect0, ISelect1 的 concrete type。

objSelect.GetType().FullName

from jint.

hyzx86 avatar hyzx86 commented on July 17, 2024

@Genteure
With the help of @viruscamp , I have reproduced this problem using the code he provided.

image

from jint.

hyzx86 avatar hyzx86 commented on July 17, 2024

@hyzx86 我是想问它的实际运行时的类型是什么,方便我确认一下现在的 unit test 是否能代表实际你遇到的问题。我对那个项目不熟悉,项目里面的抽象层又太多,我在 GitHub 上搜索代码找不到一个实现了 ISelect0, ISelect1 的 concrete type。

objSelect.GetType().FullName

FreeSql.Sqlite.Curd.SqliteSelect`1[[System.Object, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]

from jint.

hyzx86 avatar hyzx86 commented on July 17, 2024

@Genteure 就在这个链接下,有个单元测试,返回的东西跟我的测试应该是一样的

https://github.com/dotnetcore/FreeSql/blob/d40036dce8ecdef8d5b618fc5dfc07d3714ce778/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs#L455-L457

select 的类型是:

https://github.com/dotnetcore/FreeSql/blob/d40036dce8ecdef8d5b618fc5dfc07d3714ce778/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs#L20C9-L20C59

from jint.

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.