dotnet / dotnet/vscode-csharp

Extension not decompiling nuget packages right SqlCommand & SqlReader

Open
#6,394 2 comments 1 reaction 0 assignees View on GitHub
Bug External-Issue Triaged
Dominant language
TypeScript
Stars
3.1k
Forks
737
Avg merge
18h 40m
Merged PRs (30d)
31

Description

## Environment data

`dotnet --info` output:

```
.NET SDK:
Version: 7.0.110
Commit: ba920f88ac

Runtime Environment:
OS Name: fedora
OS Version: 38
OS Platform: Linux
RID: fedora.38-x64
Base Path: /usr/lib64/dotnet/sdk/7.0.110/

Host:
Version: 7.0.10
Architecture: x64
Commit: a6dbb800a4

.NET SDKs installed:
7.0.110 [/usr/lib64/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.10 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.10 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
DOTNET_ROOT [/usr/lib64/dotnet]

global.json file:
Not found
```

VS Code version: 1.82.2
C# Extension version: v2.1.2

## Steps to reproduce

1. Install this package https://www.nuget.org/packages/Microsoft.Data.SqlClient/5.1.1
2. Write this code

```c#
using Microsoft.Data.SqlClient;

var builder = new SqlConnectionStringBuilder
{
DataSource = "localhost",
UserID = "sa",
Password = "",
InitialCatalog = ""
};

try
{
using var connection = new SqlConnection(builder.ConnectionString);

Console.WriteLine("\nQuery data example:");
Console.WriteLine("=========================================\n");

connection.Open();

var sql = "SELECT name, age FROM People";

using var command = new SqlCommand(sql, connection);
using var reader = command.ExecuteReader();

while (reader.Read())
{
Console.WriteLine("{0} {1}", reader.GetString(0), reader.GetInt32(1));
}
}
catch (SqlException e)
{
Console.WriteLine(e);
}

Console.WriteLine("\nDone. Press enter.");
```

3. Ctrl + Click the ExecuteReader method

## Expected behavior
Decompiled library successfully with intellisense working

## Actual behavior

![image](https://github.com/dotnet/vscode-csharp/assets/7959437/5a2efb00-399b-4867-8f24-81257b69d249)

Notice there is no type inference for SqlDataReader and its return type is null

## Additional context

When getting intellisense for reader, the list is not complete. In this case is missing the `Dispose()` method.

![image](https://github.com/dotnet/vscode-csharp/assets/7959437/3ced9796-bab6-49ee-b1ab-7457f4a64ed7)

Looking at SqlClient source code for v5.1.1 the method is [defined](https://github.com/dotnet/SqlClient/blob/v5.1.1/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs#L830) without a [EditorBrowsable(EditorBrowsableState.Never)] data annotation so it should be showed.

Also tested with VS Code C# Extension v1.26.0, it works but the decompiling is different compared to the source.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.