Ejemplo n.º 1
0
            public string ToString(ImpactDataSet.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 2
0
            public string ToString(BookTeachesNothing.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 3
0
            public string ToString(PerkEntryPointSetText.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 4
0
            public string ToString(ConditionFloat.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
            public string ToString(MagicEffectGuideArchetype.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 6
0
            public string ToString(PexObjectVariableData.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 7
0
            public string ToString(NpcSound.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
            public string ToString(PerkEntryPointAddRangeToValue.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 9
0
            public string ToString(DistantLODData.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 10
0
            public string ToString(LeveledSpell.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
            public string ToString(PlacedPrimitive.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 12
0
            public string ToString(ScriptFragment.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 13
0
            public string ToString(ALocationTarget.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
            public string ToString(PackageRoot.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 15
0
            public override string ToString()
            {
                var fg = new FileGeneration();

                ToString(fg, null);
                return(fg.ToString());
            }
Ejemplo n.º 16
0
            public string ToString(AlternateTexture.Mask <bool>?printMask = null)
            {
                var fg = new FileGeneration();

                ToString(fg, printMask);
                return(fg.ToString());
            }
Ejemplo n.º 17
0
        public string ToString(
            ILensFlareGetter item,
            string?name = null,
            LensFlare.Mask <bool>?printMask = null)
        {
            var fg = new FileGeneration();

            ToString(
                item: item,
                fg: fg,
                name: name,
                printMask: printMask);
            return(fg.ToString());
        }
        public string ToString(
            IActorValueInformationGetter item,
            string?name = null,
            ActorValueInformation.Mask <bool>?printMask = null)
        {
            var fg = new FileGeneration();

            ToString(
                item: item,
                fg: fg,
                name: name,
                printMask: printMask);
            return(fg.ToString());
        }
Ejemplo n.º 19
0
        public string ToString(
            IVirtualMachineAdapterGetter item,
            string?name = null,
            VirtualMachineAdapter.Mask <bool>?printMask = null)
        {
            var fg = new FileGeneration();

            ToString(
                item: item,
                fg: fg,
                name: name,
                printMask: printMask);
            return(fg.ToString());
        }
        public string ToString(
            IMagicEffectWerewolfArchetypeGetter item,
            string?name = null,
            MagicEffectWerewolfArchetype.Mask <bool>?printMask = null)
        {
            var fg = new FileGeneration();

            ToString(
                item: item,
                fg: fg,
                name: name,
                printMask: printMask);
            return(fg.ToString());
        }
Ejemplo n.º 21
0
        public string ToString(
            ISoundDescriptorGetter item,
            string?name = null,
            SoundDescriptor.Mask <bool>?printMask = null)
        {
            var fg = new FileGeneration();

            ToString(
                item: item,
                fg: fg,
                name: name,
                printMask: printMask);
            return(fg.ToString());
        }
        public string ToString(
            ISpellLeveledGetter item,
            string?name = null,
            SpellLeveled.Mask <bool>?printMask = null)
        {
            var fg = new FileGeneration();

            ToString(
                item: item,
                fg: fg,
                name: name,
                printMask: printMask);
            return(fg.ToString());
        }
Ejemplo n.º 23
0
        public string ToString(
            IImpactDataSetGetter item,
            string?name = null,
            ImpactDataSet.Mask <bool>?printMask = null)
        {
            var fg = new FileGeneration();

            ToString(
                item: item,
                fg: fg,
                name: name,
                printMask: printMask);
            return(fg.ToString());
        }
Ejemplo n.º 24
0
        public string ToString(
            IPlacedObjectGetter item,
            string?name = null,
            PlacedObject.Mask <bool>?printMask = null)
        {
            var fg = new FileGeneration();

            ToString(
                item: item,
                fg: fg,
                name: name,
                printMask: printMask);
            return(fg.ToString());
        }
Ejemplo n.º 25
0
        public static async Task RunTests(TestingSettings settings)
        {
            int passed = 0;
            int failed = 0;

            await foreach (var test in GetTests(settings: settings))
            {
                using var sub = test.AllOutput.Subscribe(msg =>
                {
                    System.Console.WriteLine(msg);
                });
                try
                {
                    await test.Start();

                    passed += 1 + test.ChildCount;
                }
                catch (Exception ex)
                {
                    failed += 1 + test.ChildCount;
                    if (ex is IPrintable printable)
                    {
                        FileGeneration fg = new FileGeneration();
                        printable.ToString(fg);
                        var str = fg.ToString();
                        System.Console.Write(fg);
                        System.Console.WriteLine();
                    }
                    else
                    {
                        System.Console.WriteLine(ex);
                    }
                }
                await test.Output.LastOrDefaultAsync();

                GC.Collect();
            }
            if (failed == 0)
            {
                System.Console.WriteLine("All passed");
            }
            else
            {
                System.Console.WriteLine($"{failed} / {(passed + failed)} failed");
            }
        }
        public void Execute(GeneratorExecutionContext context)
        {
            if (context.CancellationToken.IsCancellationRequested)
            {
                return;
            }
            if (context.SyntaxReceiver is not CustomAspectInterfaceReceiver customAspectReceiver)
            {
                return;
            }

            try
            {
                if (context.CancellationToken.IsCancellationRequested)
                {
                    return;
                }
                var interfaceSymbols = GetInterfaceTypeDictionary(context, customAspectReceiver);

                // Group things by namespace
                if (context.CancellationToken.IsCancellationRequested)
                {
                    return;
                }
                var targets = new Dictionary <string, GenerationTarget>();

                foreach (var namespaceGroup in interfaceSymbols.Values
                         .GroupBy(x => x.Symbol.ContainingNamespace))
                {
                    targets[namespaceGroup.Key.Name] = new GenerationTarget(
                        namespaceGroup.Key.Name,
                        namespaceGroup,
                        new());
                }

                HashSet <string> requiredUsings = new(targets.SelectMany(x => x.Value.UsedInterfaces)
                                                      .SelectMany(x => x.Types)
                                                      .Select(i => i.Symbol)
                                                      .NotNull()
                                                      .Select(x => x.ContainingNamespace.ToString()));

                // Generate
                foreach (var namespaceGroup in targets)
                {
                    if (context.CancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    var fg = new FileGeneration();

                    foreach (var use in requiredUsings)
                    {
                        fg.AppendLine($"using {use};");
                    }
                    fg.AppendLine();

                    using (new NamespaceWrapper(fg, namespaceGroup.Key))
                    {
                        using (new RegionWrapper(fg, "Wrappers"))
                        {
                            foreach (var decl in namespaceGroup.Value.UsedInterfaces)
                            {
                                if (context.CancellationToken.IsCancellationRequested)
                                {
                                    return;
                                }
                                foreach (var t in decl.Types)
                                {
                                    var className = $"{t.Syntax.Type}Wrapper";
                                    using (var c = new ClassWrapper(fg, className))
                                    {
                                        c.Interfaces.Add(decl.Symbol.Name);
                                    }
                                    using (new BraceWrapper(fg))
                                    {
                                        fg.AppendLine($"private readonly {t.Syntax.Type} _wrapped;");
                                        foreach (var member in decl.Symbol.GetMembers())
                                        {
                                            switch (member)
                                            {
                                            case IPropertySymbol prop:
                                                fg.AppendLine($"public {prop.Type} {prop.Name}");
                                                using (new BraceWrapper(fg))
                                                {
                                                    if (!prop.IsWriteOnly)
                                                    {
                                                        fg.AppendLine($"get => _wrapped.{member.Name};");
                                                    }
                                                    if (!prop.IsReadOnly)
                                                    {
                                                        fg.AppendLine($"set => _wrapped.{member.Name} = value;");
                                                    }
                                                }
                                                break;

                                            default:
                                                continue;
                                            }
                                            fg.AppendLine();
                                        }

                                        using (var args = new FunctionWrapper(fg, $"public {className}"))
                                        {
                                            args.Add($"{t.Syntax.Type} rhs");
                                        }
                                        using (new BraceWrapper(fg))
                                        {
                                            fg.AppendLine("_wrapped = rhs;");
                                        }
                                    }
                                    fg.AppendLine();
                                }
                            }
                            fg.AppendLine();
                        }

                        if (context.CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        using (new RegionWrapper(fg, "Mix Ins"))
                        {
                            using (var c = new ClassWrapper(fg, "WrapperMixIns"))
                            {
                                c.Static = true;
                            }
                            using (new BraceWrapper(fg))
                            {
                                foreach (var decl in namespaceGroup.Value.UsedInterfaces)
                                {
                                    if (context.CancellationToken.IsCancellationRequested)
                                    {
                                        return;
                                    }
                                    foreach (var t in decl.Types)
                                    {
                                        using (var args = new FunctionWrapper(fg,
                                                                              $"public static {t.Syntax.Type}Wrapper As{decl.Symbol.Name}"))
                                        {
                                            args.Add($"this {t.Syntax.Type} rhs");
                                        }
                                        using (new BraceWrapper(fg))
                                        {
                                            fg.AppendLine($"return new {t.Syntax.Type}Wrapper(rhs);");
                                        }
                                        fg.AppendLine();
                                    }
                                }
                            }
                        }
                    }
                    context.AddSource($"CustomAspectInterfaces.g.cs", fg.ToString());
                }
            }
            catch (Exception ex)
            {
                customAspectReceiver.Exceptions.Add(ex);
            }

            if (customAspectReceiver.Exceptions.Count > 0)
            {
                context.AddSource($"Errors.g.cs", $"Number of exceptions: {customAspectReceiver.Exceptions.Count}\n" +
                                  $"{customAspectReceiver.Exceptions.FirstOrDefault()}");
            }
        }
Ejemplo n.º 27
0
 public string ToString(LocationFallback.Mask<bool>? printMask = null)
 {
     var fg = new FileGeneration();
     ToString(fg, printMask);
     return fg.ToString();
 }
Ejemplo n.º 28
0
 public string ToString(LeveledItemEntryData.Mask<bool>? printMask = null)
 {
     var fg = new FileGeneration();
     ToString(fg, printMask);
     return fg.ToString();
 }
Ejemplo n.º 29
0
 public string ToString(SkillData.Mask<bool>? printMask = null)
 {
     var fg = new FileGeneration();
     ToString(fg, printMask);
     return fg.ToString();
 }