/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Validation/gen/Parsers/ValidationsGenerator.AttributeParser.cs
30 строк
1 KB
Youssef Victor
Cleanup ValidationsGenerator for better incrementality (#66373)
28 апр 2026, 22:45
Не верифицирован
28 апр 2026, 22:45
b58523d
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; using System.Collections.Immutable; using System.Threading; using Microsoft.AspNetCore.App.Analyzers.Infrastructure; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; namespace Microsoft.Extensions.Validation; public sealed partial class ValidationsGenerator : IIncrementalGenerator { internal static bool ShouldTransformSymbolWithAttribute(SyntaxNode syntaxNode, CancellationToken cancellationToken) { return syntaxNode.IsKind(SyntaxKind.ClassDeclaration) || syntaxNode.IsKind(SyntaxKind.RecordDeclaration); } internal static ImmutableArray<ValidatableType> TransformValidatableTypeWithAttribute(GeneratorAttributeSyntaxContext context, CancellationToken cancellationToken) { var validatableTypes = new HashSet<ValidatableType>(ValidatableTypeComparer.Instance); List<ITypeSymbol> visitedTypes = []; var wellKnownTypes = WellKnownTypes.GetOrCreate(context.SemanticModel.Compilation); if (TryExtractValidatableType((ITypeSymbol)context.TargetSymbol, wellKnownTypes, validatableTypes, visitedTypes)) { return [.. validatableTypes]; } return []; } }