Version Used: Visual Studio 17.1 Preview 1
Steps to Reproduce:
- Paste the following code (pls don't judge me 🙈)
using System.Runtime.CompilerServices;
public ref struct A
{
private void Foo()
{
}
public readonly unsafe ref struct B
{
private readonly void* a;
public void Dispose()
{
((delegate*<ref byte, ref A>)(delegate*<ref byte, ref byte>)&Unsafe.As<byte, byte>)(ref *(byte*)a).Foo();
}
}
}
Expected Behavior:
Nothing should happen, this code is fine. Trust me.
Actual Behavior:
IntelliSense suggests to "simplify the name" on that Dispose line, which just nukes everything except Foo(). This obviously results in a compile error, given that B does not have a method named Foo() (and also removing that previous code is semantically different). Interestingly enough, the preview window for the refactor already shows the red quiggly line over the resulting Foo() call, so it would seem Roslyn does at least in part know already that the refactoring is actually invalid.
cc. @333fred @jaredpar just because Fred will probably block me on Discord after this, and Jared will probably have a laugh 😄
Additional notes:
Here's a smaller repro (note though that this code instead wouldn't actually be useful, but it's just to show the issue):
public struct A
{
private void Foo()
{
}
public readonly unsafe struct B
{
private readonly void* a;
public void Dispose()
{
((delegate*<ref byte, ref A>)&Unsafe.As<byte, A>)(ref *(byte*)a).Foo();
}
}
}
Version Used: Visual Studio 17.1 Preview 1
Steps to Reproduce:
Expected Behavior:
Nothing should happen, this code is fine. Trust me.
Actual Behavior:
IntelliSense suggests to "simplify the name" on that
Disposeline, which just nukes everything exceptFoo(). This obviously results in a compile error, given thatBdoes not have a method namedFoo()(and also removing that previous code is semantically different). Interestingly enough, the preview window for the refactor already shows the red quiggly line over the resultingFoo()call, so it would seem Roslyn does at least in part know already that the refactoring is actually invalid.cc. @333fred @jaredpar just because Fred will probably block me on Discord after this, and Jared will probably have a laugh 😄
Additional notes:
Here's a smaller repro (note though that this code instead wouldn't actually be useful, but it's just to show the issue):