58 references to OutLn
Microsoft.Extensions.Options.SourceGeneration (58)
Emitter.cs (55)
106OutLn($"namespace {vt.Namespace}");
112OutLn(p);
119OutLn($"internal sealed partial {vt.DeclarationKeyword} {vt.Name}");
123OutLn($"partial {vt.DeclarationKeyword} {vt.Name}");
150OutLn($"namespace {classNamespace}");
154OutLn($"{_optionsSourceGenContext.ClassModifier} static class {className}");
200OutLn($$"""
247OutLn($$"""
293OutLn($$"""
343OutLn($$"""
454OutLn($$"""
622OutLn($"namespace {StaticGeneratedValidationAttributesClassesNamespace}");
660OutLn($"context.MemberName = \"Validate\";");
661OutLn($"context.DisplayName = string.IsNullOrEmpty(name) ? \"{modelName}.Validate\" : $\"{{name}}.Validate\";");
662OutLn($"(builder ??= new()).AddResults(((global::System.ComponentModel.DataAnnotations.IValidatableObject)options).Validate(context));");
673OutLn($"/// <summary>");
674OutLn($"/// Validates a specific named options instance (or all when <paramref name=\"name\"/> is <see langword=\"null\" />).");
675OutLn($"/// </summary>");
676OutLn($"/// <param name=\"name\">The name of the options instance being validated.</param>");
677OutLn($"/// <param name=\"options\">The options instance.</param>");
678OutLn($"/// <returns>Validation result.</returns>");
686OutLn("#if !NET10_0_OR_GREATER");
687OutLn($"[System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage(\"Trimming\", \"IL2026:RequiresUnreferencedCode\",");
688OutLn($" Justification = \"The created ValidationContext object is used in a way that never call reflection\")]");
689OutLn("#endif");
692OutLn($"public {(makeStatic ? "static " : string.Empty)}global::Microsoft.Extensions.Options.ValidateOptionsResult Validate(string? name, {modelToValidate.Name} options)");
694OutLn($"global::Microsoft.Extensions.Options.ValidateOptionsResultBuilder? builder = null;");
695OutLn("#if NET10_0_OR_GREATER");
696OutLn($"string displayName = string.IsNullOrEmpty(name) ? \"{modelToValidate.SimpleName}.Validate\" : $\"{{name}}.Validate\";");
697OutLn($"var context = new {StaticValidationContextType}(options, displayName, null, null);");
698OutLn("#else");
699OutLn($"var context = new {StaticValidationContextType}(options);");
700OutLn("#endif");
705OutLn($"var validationResults = new {StaticListType}<{StaticValidationResultType}>();");
706OutLn($"var validationAttributes = new {StaticListType}<{StaticValidationAttributeType}>({capacity});");
734OutLn($"return builder is null ? global::Microsoft.Extensions.Options.ValidateOptionsResult.Success : builder.Build();");
740OutLn($"context.MemberName = \"{vm.Name}\";");
741OutLn($"context.DisplayName = string.IsNullOrEmpty(name) ? \"{modelName}.{vm.Name}\" : $\"{{name}}.{vm.Name}\";");
745OutLn($"validationResults.Clear();");
746OutLn($"validationAttributes.Clear();");
752OutLn($"validationAttributes.Add({_staticValidationAttributeHolderClassFQN}.{staticValidationAttributeInstance.FieldName});");
755OutLn($"if (!global::System.ComponentModel.DataAnnotations.Validator.TryValidateValue(options.{vm.Name}{_TryGetValueNullableAnnotation}, context, validationResults, validationAttributes))");
757OutLn($"(builder ??= new()).AddResults(validationResults);");
841OutLn($"if (options.{vm.Name} is not null)");
843OutLn($"(builder ??= new()).AddResult({callSequence}.Validate({baseName}, options.{vm.Name}{valueAccess}));");
848OutLn($"(builder ??= new()).AddResult({callSequence}.Validate({baseName}, options.{vm.Name}{valueAccess}));");
870OutLn($"if (options.{vm.Name} is not null)");
875OutLn($"var count = 0;");
876OutLn($"foreach (var o in options.{vm.Name}{valueAccess})");
881OutLn($"if (o is not null)");
884OutLn($"(builder ??= new()).AddResult({callSequence}.Validate({propertyName}, o{enumeratedValueAccess}));");
889OutLn($"else");
892OutLn($"(builder ??= new()).AddError({error});");
896OutLn($"count++;");
901OutLn($"(builder ??= new()).AddResult({callSequence}.Validate({propertyName}, o{enumeratedValueAccess}));");