diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs index bbdec6de9a01e..934010a8e341b 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs @@ -1713,7 +1713,7 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute( WellKnownMember.System_Reflection_DefaultMemberAttribute__ctor, - ImmutableArray.Create(defaultMemberNameConstant))); + ImmutableArray.Create(defaultMemberNameConstant), isOptionalUse: true)); } if (this.declaration.Declarations.All(d => d.IsSimpleProgram)) diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/IndexerTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/IndexerTests.cs index 962aad44400e0..8741173f383e1 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/IndexerTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/IndexerTests.cs @@ -1185,5 +1185,21 @@ static void Main() } #endregion Lowering + + [Fact] + [WorkItem("https://github.com/dotnet/roslyn/issues/75032")] + public void MissingDefaultMemberAttribute() + { + var text = @" +interface I1 +{ + I1 this[I1 args] { get; } +} +"; + var comp = CreateCompilation(text); + comp.MakeMemberMissing(WellKnownMember.System_Reflection_DefaultMemberAttribute__ctor); + + CompileAndVerify(comp).VerifyDiagnostics(); + } } }