Repository: dotnet/roslyn
File: src/Compilers/CSharp/Test/Semantic/Semantics/MethodTypeInferenceTests.cs (C#)

Code before:
public class Test
{
    public static void NoIntellisenseInEnumerableJoin()
    {
        IEnumerable<Book> books = null;
        IEnumerable<Author> authors = null;

        var test = books.Join(authors, b => b.AuthorId, a => a.Id, (bookResult, authorResult) => new { bookResult, authorResult });
    }
}";

            var compilation = CreateCSharpCompilation(source).VerifyDiagnostics();
            var tree = compilation.SyntaxTrees.Single();
            var model = compilation.GetSemanticModel(tree);

            var bookResult = (IdentifierNameSyntax)tree.GetRoot().DescendantTokens().Last(t => t.Text == "bookResult").Parent;
            var bookResultType = model.GetTypeInfo(bookResult).Type;
            Assert.Equal("Book", bookResultType.Name);

            var authorResult = (IdentifierNameSyntax)tree.GetRoot().DescendantTokens().Last(t => t.Text == "authorResult").Parent;
            var authorResultType = model.GetTypeInfo(authorResult).Type;
            Assert.Equal("Author", authorResultType.Name);
        }

        [WorkItem("https://developercommunity.visualstudio.com/t/InterlockedExchange:-compiler-choses-wr/1259784")]
        [Fact]
        public void InterlockedExchangeWithNullableTypes()
        {
            string source = """
                #nullable enable
                using System.Threading;

                namespace InterlockedExchangeNullProblem
                {
                    public class Class1
                    {
                        public void Method()
                        {
                            object? o = new object();
                            var o1 = Interlocked.Exchange(ref o, null);

                            class2? c = new class2();
                            var c1 = Interlocked.Exchange(ref c, null);
                            var c2 = Interlocked.Exchange<class2?>(ref c, null);
                        }
                    }
                    public class class2 { }
                }
                """;

            var comp = CreateCompilation(source);

Review comment (suggestion):
```suggestion
        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/49525")]
```

Code after:
public class Test
{
    public static void NoIntellisenseInEnumerableJoin()
    {
        IEnumerable<Book> books = null;
        IEnumerable<Author> authors = null;

        var test = books.Join(authors, b => b.AuthorId, a => a.Id, (bookResult, authorResult) => new { bookResult, authorResult });
    }
}";

            var compilation = CreateCSharpCompilation(source).VerifyDiagnostics();
            var tree = compilation.SyntaxTrees.Single();
            var model = compilation.GetSemanticModel(tree);

            var bookResult = (IdentifierNameSyntax)tree.GetRoot().DescendantTokens().Last(t => t.Text == "bookResult").Parent;
            var bookResultType = model.GetTypeInfo(bookResult).Type;
            Assert.Equal("Book", bookResultType.Name);

            var authorResult = (IdentifierNameSyntax)tree.GetRoot().DescendantTokens().Last(t => t.Text == "authorResult").Parent;
            var authorResultType = model.GetTypeInfo(authorResult).Type;
            Assert.Equal("Author", authorResultType.Name);
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/49525")]
        public void InterlockedExchangeWithNullableTypes()
        {
            var source = """
                #nullable enable
                using System.Threading;

                namespace InterlockedExchangeNullProblem
                {
                    public class Class1
                    {
                        public void Method()
                        {
                            object? o = new object();
                            var o1 = Interlocked.Exchange(ref o, null);

                            class2? c = new class2();
                            var c1 = Interlocked.Exchange(ref c, null);
                            var c2 = Interlocked.Exchange<class2?>(ref c, null);
                        }
                    }
                    public class class2 { }
                }
                """;

            CreateCompilation(source).VerifyEmitDiagnostics();
        }