zompinc/sync-method-generator

Collection in collection cannot determine type T

Closed this issue · 2 comments

Consider the following code

        [Zomp.SyncMethodGenerator.CreateSyncVersion(OmitNullableDirective = true)]
        protected async Task Foo1Async()
        {
            var dict = new Dictionary<DateTime, int>();
            await Task.Delay(1000);
        }

        [Zomp.SyncMethodGenerator.CreateSyncVersion(OmitNullableDirective = true)]
        protected async Task Foo2Async()
        {
            var dict = new Dictionary<DateTime, List<int>>();
            await Task.Delay(1000);
        }

        [Zomp.SyncMethodGenerator.CreateSyncVersion(OmitNullableDirective = true)]
        protected async Task Foo3Async()
        {
            var dict = new Dictionary<DateTime, Dictionary<int, string>>();
            await Task.Delay(1000);
        }

Foo1Async compiles fine, but 2 and 3 doesn't, let's focus on Foo2Async, it generates the following

        protected void Foo2()
        {
            var dict = new global::System.Collections.Generic.Dictionary<DateTime, global::System.Collections.Generic.List<int>>();
            global::System.Threading.Thread.Sleep(1000);
        }

Which compiles with the following error

error CS0246: The type or namespace name 'DateTime' could not be found (are you missing a using directive or an assembly reference?)

Version 1.3.44 fixes this issue. Thanks for raising all these issues.

IT seems to work 👍