| File: Language\Extensions\InheritsDirectivePass.cs | Web Access |
| Project: src\roslyn\src\Razor\src\Compiler\Microsoft.CodeAnalysis.Razor.Compiler\src\Microsoft.CodeAnalysis.Razor.Compiler.csproj (Microsoft.CodeAnalysis.Razor.Compiler) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Linq; using System.Threading; using Microsoft.AspNetCore.Razor.Language.Intermediate; namespace Microsoft.AspNetCore.Razor.Language.Extensions; public sealed class InheritsDirectivePass : IntermediateNodePassBase, IRazorDirectiveClassifierPass { protected override void ExecuteCore( RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode, CancellationToken cancellationToken) { var @class = documentNode.FindPrimaryClass(); if (@class == null) { return; } foreach (var inherits in documentNode.FindDirectiveReferences(InheritsDirective.Directive)) { var token = inherits.Node.Tokens.FirstOrDefault(); if (token != null) { @class.BaseType = new BaseTypeWithModel(token.Content, token.Source); break; } } } }