Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SocketAsyncEventArgs.Completed event nullability is incorrectly written #93

Open
jnm2 opened this issue Aug 13, 2023 · 0 comments
Open

Comments

@jnm2
Copy link
Contributor

jnm2 commented Aug 13, 2023

ReferenceAssemblyAnnotator creates SocketAsyncEventArgs.Completed with a bizarre nullable event args parameter:

image

No diagnostic should be shown here. When compiling on net6.0, there is no diagnostic for this sample code.

I decompiled %userprofile\.nuget\packages\microsoft.netcore.app.ref\6.0.0\ref\net6.0\System.Net.Sockets.dll and confirmed that it has public event EventHandler<SocketAsyncEventArgs>? Completed;, not public event EventHandler<SocketAsyncEventArgs?>? Completed;.

Repro

using System.Net.Sockets;

var x = new SocketAsyncEventArgs();

// ⚠️ CS8622 Nullability of reference types in type of parameter 'e' of 'void OnCompleted(object? sender,
// SocketAsyncEventArgs e)' doesn't match the target delegate 'EventHandler<SocketAsyncEventArgs?>' (possibly
// because of nullability attributes).
//             ↓↓↓↓↓↓↓↓↓↓↓
x.Completed += OnCompleted;

void OnCompleted(object? sender, SocketAsyncEventArgs e)
{
}
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net48</TargetFramework>
    <Nullable>enable</Nullable>
    <LangVersion>11</LangVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.160" />
    <PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[6.0.0]" />
  </ItemGroup>

</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant