Skip to content

Commit

Permalink
Merge pull request #107 from li-zhixin/master
Browse files Browse the repository at this point in the history
修复 对象数组作为参数时,代码生成器 空指针异常
  • Loading branch information
walterlv authored Oct 31, 2022
2 parents 4eda4a1 + 3711e1e commit 29b42c6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public SourceTextBuilder AddUsingForTypes(params ITypeSymbol[] typeSymbols)
public string SimplifyNameByAddUsing(ITypeSymbol typeSymbol)
{
var originalName = typeSymbol.ToString();
var @namespace = typeSymbol.ContainingNamespace.ToString();
var @namespace = typeSymbol.ContainingNamespace?.ToString();
if (@namespace == null)
{
return originalName;
}
if (originalName.StartsWith(@namespace, StringComparison.Ordinal))
{
// 常规类型,“命名空间.类名”型。
Expand Down

0 comments on commit 29b42c6

Please sign in to comment.