Skip to content

Commit

Permalink
fix(ProvideAttribute): fix NullReferenceException during codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
jonisavo committed Nov 20, 2022
1 parent 43c8fba commit 2b03eb7
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private void GetProvideDescriptions(AugmentGenerationContext context, IList<Prov
if (!(member is IFieldSymbol fieldSymbol))
continue;

var memberType = RoslynUtilities.GetMemberType(member) as INamedTypeSymbol;
var memberType = fieldSymbol.Type;

if (memberType == null)
continue;
Expand Down Expand Up @@ -72,9 +72,13 @@ private void GetProvideDescriptions(AugmentGenerationContext context, IList<Prov
protected override bool ShouldGenerateSource(AugmentGenerationContext context)
{
_provideDescriptions.Clear();

if (_provideAttributeSymbol == null)
return false;

GetProvideDescriptions(context, _provideDescriptions);

return _provideAttributeSymbol != null && _provideDescriptions.Count > 0;
return _provideDescriptions.Count > 0;
}

protected override void BuildUsingStatements(StringBuilder stringBuilder)
Expand Down

0 comments on commit 2b03eb7

Please sign in to comment.