Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Fix issue #207 (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgriffin authored Oct 22, 2020
1 parent c6bedd5 commit f354299
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/MDK/Build/AnalysisExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static string GetFullName(this ISymbol symbol, DeclarationFullNameFlags f
{
var declaratorSyntax = namedType
.DeclaringSyntaxReferences
.First()
.GetSyntax();
.FirstOrDefault()
?.GetSyntax();
if (declaratorSyntax is TypeDeclarationSyntax typeDeclaration)
{
return typeDeclaration.GetFullName(flags);
Expand Down
11 changes: 11 additions & 0 deletions Source/MDK/Build/Composers/Minifying/CodeSimplifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ bool IsInProgram(SyntaxNode node)
return false;
}

static string GetFullName(INamedTypeSymbol symbol) => symbol.GetFullName(DeclarationFullNameFlags.WithoutNamespaceName);

public async Task<ProgramComposition> ProcessAsync(ProgramComposition composition, MDKProjectProperties config)
{
var newDocument = await Simplifier.ReduceAsync(composition.Document).ConfigureAwait(false);
Expand All @@ -272,7 +274,16 @@ public async Task<ProgramComposition> ProcessAsync(ProgramComposition compositio
{
var node = composition.RootNode.FindNode(location.Location.SourceSpan);
if (!IsInProgram(node))
{
_externallyReferencedMembers.Add(typeUsage.FullName);
if (typeUsage.Symbol is ITypeSymbol typeSymbol)
{
foreach (var interfaceName in typeSymbol.AllInterfaces.Select(GetFullName))
_externallyReferencedMembers.Add(interfaceName);
if(typeSymbol.BaseType != null)
_externallyReferencedMembers.Add(GetFullName(typeSymbol.BaseType));
}
}
}
}
}
Expand Down

0 comments on commit f354299

Please sign in to comment.