Skip to content

Added null checks on F# external access services#36469

Merged
TIHan merged 2 commits intodotnet:masterfrom
TIHan:fsharp-shim-null-checks
Jun 14, 2019
Merged

Added null checks on F# external access services#36469
TIHan merged 2 commits intodotnet:masterfrom
TIHan:fsharp-shim-null-checks

Conversation

@TIHan
Copy link
Copy Markdown
Contributor

@TIHan TIHan commented Jun 14, 2019

We need to check for nulls when we map F# types to Roslyn types, vice versa, for the shim work. We got a crash in FSharpSignatureHelpProvider for this reason. I fixed the sig help provider, but I also put more null checks in the other places that potentially could need it.

@TIHan TIHan requested a review from a team as a code owner June 14, 2019 21:26
if (mappedSignatureHelpItems != null)
{
return new SignatureHelpItems(
mappedSignatureHelpItems.Items?.Select(x =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will throw if it's null and also if it's empty. The whole function should return null instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but at least it will throw inside SignatureHelpItems. It's going to throw no matter what if that is null. This just adds another guard check.

FSharpGlyphHelpers.ConvertTo(item.Glyph),
item.Spans,
item.ChildItems.Select(x => ConvertToNavigationBarItem(x)).ToList(),
item.ChildItems?.Select(x => ConvertToNavigationBarItem(x)).ToList(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might throw, it may be preferred to return null from this function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a conversion and private. item really should never be null because the mapping happens on a collection.

@TIHan TIHan merged commit 90743fb into dotnet:master Jun 14, 2019
333fred added a commit to 333fred/roslyn that referenced this pull request Jun 18, 2019
…-types

* dotnet/master: (63 commits)
  Fix stack overflow in requesting syntax directives (dotnet#36347)
  crash on ClassifyUpdate for EventFields (dotnet#35962)
  Disable move type when the options service isn't present (dotnet#36334)
  Fix crash where type inference doing method inference needs to drop nullability
  Fix parsing bug in invalid using statements (dotnet#36428)
  Do not suggest or diagnose use compound assignment when right hand of binary operator is a throw expression
  Add option to emit nullable metadata for public members only (dotnet#36398)
  Added null checks on F# external access services (dotnet#36469)
  Deal with discovering extra .editorconfig files
  Re-enable MSBuildWorkspaceTests.TestEditorConfigDiscovery
  Add support to VisualStudioMSBuildInstalled to support minimum versions
  Fix configuration of accessibilities in editorconfig
  Shorten a resource ID
  Revert "Extract the RDT implementation for Misc files and VS open file tracker"
  Add nullability support to use local function
  Add EditorFeatures.WPF dependency to F# ExternalAccess
  Ensure NullableWalker.AsMemberOfType locates the right new container for the member. (dotnet#36406)
  Replace `dynamic` with `object` when substituting constraints. (dotnet#36379)
  Add some string descriptions
  Adjust type of out var based on parameter state (dotnet#36284)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants