예제 #1
0
        private void InjectINPCProperties(GeneratorExecutionContext context)
        {
            if (!(context.SyntaxReceiver is INPCReceiver receiver))
            {
                throw new InvalidProgramException("Receiver is the wrong type");
            }

            var elaboratedClasses = receiver.ClassesToAugment.Values
                                    .Select(i => i.ElaborateSemanticInfo(context.Compilation))
                                    .ToList();

            var factory = new InpcClassGeneratorFactory(elaboratedClasses,
                                                        context.Compilation.GetSpecialType(SpecialType.System_String));

            var namer = new GeneratedFileUniqueNamer("INPC");


            foreach (var augmenter in elaboratedClasses)
            {
                factory.CreateGenerator(augmenter, context).Generate(namer);
            }
        }
예제 #2
0
 protected PartialTypeGenerator(string suffix, params string[] targetAttributes)
 {
     this.suffix           = suffix;
     this.targetAttributes = targetAttributes;
     namer = new(suffix);
 }
예제 #3
0
 public void Generate(GeneratedFileUniqueNamer namer)
 {
     codeWriter.AppendLine("#nullable enable");
     GenerateCodeForClass();
     codeWriter.PublishCodeInFile(namer.CreateFileName(ClassName()));
 }