Skip to content

Commit f69543d

Browse files
Fixed NullReferenceException
1 parent dc848b0 commit f69543d

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/toolkit/Community.VisualStudio.Toolkit.Shared/MEF/TokenErrorTaggerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public override IEnumerable<ITagSpan<IErrorTag>> GetTags(NormalizedSnapshotSpanC
5959
}
6060
}
6161

62-
private static string GetErrorType(IList<ErrorListItem> errors)
62+
private static string GetErrorType(IEnumerable<ErrorListItem> errors)
6363
{
6464
return errors.FirstOrDefault()?.ErrorCategory ?? PredefinedErrorTypeNames.SyntaxError;
6565
}

src/toolkit/Community.VisualStudio.Toolkit.Shared/MEF/TokenTag.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public class TokenTag : ITag
1515
/// <summary>
1616
/// Creates a new instance.
1717
/// </summary>
18-
public TokenTag(object tokenType, params ErrorListItem[] errors)
18+
public TokenTag(object tokenType, IEnumerable<ErrorListItem> errors)
1919
{
2020
TokenType = tokenType;
21-
Errors = errors;
21+
Errors = errors.ToList() ?? new();
2222
}
2323

2424
/// <summary>
@@ -29,7 +29,7 @@ public TokenTag(object tokenType, params ErrorListItem[] errors)
2929
/// <summary>
3030
/// A list of errors associated with the tag.
3131
/// </summary>
32-
public virtual IList<ErrorListItem> Errors { get; set; }
32+
public virtual IEnumerable<ErrorListItem> Errors { get; set; }
3333

3434
/// <summary>
3535
/// Returns true if there are no errors in the list.

src/toolkit/Community.VisualStudio.Toolkit.Shared/MEF/TokenTaggerBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public IEnumerable<ITagSpan<TokenTag>> GetTags(NormalizedSnapshotSpanCollection
7070
/// <param name="errors">Optional. List of errors associated with the token. This is used by the error tagger and will Error List.</param>
7171
public virtual TokenTag CreateToken(object tokenType, bool hasTooltip, bool supportOutlining, IEnumerable<ErrorListItem> errors)
7272
{
73-
return new TokenTag(tokenType, errors.ToArray())
73+
return new TokenTag(tokenType, errors)
7474
{
7575
GetTooltipAsync = hasTooltip ? GetTooltipAsync : null,
7676
GetOutliningText = supportOutlining ? GetOutliningText : null,
@@ -84,7 +84,7 @@ public virtual TokenTag CreateToken(object tokenType, bool hasTooltip, bool supp
8484
/// <returns><see langword="null"/>, or any text or WPF content to show in the tooltip (QuickInfo).</returns>
8585
public virtual Task<object> GetTooltipAsync(SnapshotPoint triggerPoint)
8686
{
87-
return Task.FromResult<object>(null);
87+
return Task.FromResult<object>(null!);
8888
}
8989

9090
/// <summary>

0 commit comments

Comments
 (0)