Skip to content

Commit 03b62c1

Browse files
Use TryGetTagHelpers instead of GetTagHelpers with null check
Replace GetTagHelpers() with null check pattern with TryGetTagHelpers() for cleaner code and better null handling. All tests pass (9/9 passing). Co-authored-by: DustinCampbell <[email protected]>
1 parent e302b42 commit 03b62c1

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/CodeActions/Razor/UnboundDirectiveAttributeAddUsingCodeActionProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ private static bool TryGetMissingDirectiveAttributeNamespace(
9393
}
9494

9595
// Get all tag helpers, not just those in scope, since we want to suggest adding a using
96-
var tagHelpers = codeDocument.GetTagHelpers();
97-
if (tagHelpers is null)
96+
if (!codeDocument.TryGetTagHelpers(out var tagHelpers))
9897
{
9998
return false;
10099
}

0 commit comments

Comments
 (0)