Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 41c92e8

Browse files
Merge pull request #44 from episerver/user/shsh/fix-base-type-name
Fallback to Qualified Name syntax (namespace + IMetadataAware)
2 parents 1198263 + c65df10 commit 41c92e8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/EpiSourceUpdater/EpiMetadataAwareCodeFixProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ private async Task<Document> RefactorToDisplayModeProvider(Document document, Cl
6262
{
6363
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
6464
var metadataType = node.BaseList.Types.OfType<BaseTypeSyntax>().FirstOrDefault(t => t.Type is IdentifierNameSyntax nameSyntax && nameSyntax.Identifier.Text == "IMetadataAware");
65+
// try to find it with qualified name synatx
66+
metadataType ??= node.BaseList.Types.OfType<SimpleBaseTypeSyntax>().FirstOrDefault(t => t.Type is QualifiedNameSyntax qualifiedNameSyntax && qualifiedNameSyntax.Right?.Identifier.Text == "IMetadataAware");
67+
if (metadataType is null)
68+
{
69+
return document;
70+
}
71+
6572
var baseListWithoutInterface = node.BaseList.RemoveNode(metadataType, SyntaxRemoveOptions.KeepLeadingTrivia | SyntaxRemoveOptions.KeepTrailingTrivia | SyntaxRemoveOptions.KeepEndOfLine);
6673
var baseListWithDisplayModeProvider = baseListWithoutInterface.AddTypes(SyntaxFactory.SimpleBaseType(SyntaxFactory.ParseTypeName("IDisplayMetadataProvider")));
6774
var withDisplayModeProvider = node.WithBaseList(baseListWithDisplayModeProvider);

0 commit comments

Comments
 (0)