Skip to content

AddOpenCodeFixProvider throws for types with attributes in implicit top-level modules #15993

@psfinaki

Description

@psfinaki

This code throws:

[<SomeAttribute>]
type MyType() =
    inherit Type ()

Stack trace:

System.Collections.Generic.KeyNotFoundException : An index satisfying the predicate was not found in the collection.
   at Microsoft.FSharp.Collections.SeqModule.loop@1146-22[T](FSharpFunc`2 predicate,IEnumerator`1 ie,Int32 i)
   at Microsoft.FSharp.Collections.SeqModule.FindIndex[T](FSharpFunc`2 predicate,IEnumerable`1 source)
   at Microsoft.VisualStudio.FSharp.Editor.AddOpenCodeFixProvider.getOpenDeclaration(SourceText sourceText,InsertionContext ctx,String ns)
   at Microsoft.VisualStudio.FSharp.Editor.AddOpenCodeFixProvider.openNamespaceFix(InsertionContext ctx,String name,String ns,Boolean multipleNames,SourceText sourceText)
   at <StartupCode$FSharp-Editor>[email protected](Tuple`4 tupledArg)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.map@128.DoMoveNext(b& curr)
   at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System.Collections.IEnumerator.MoveNext()
   at Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.takeInner@312[T,TResult](ConcatEnumerator`2 x,Unit unitVar0)
   at Microsoft.FSharp.Collections.SeqModule.TryHead[T](IEnumerable`1 source)
   at async StartupCode$FSharp-Editor(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.VisualStudio.FSharp.Editor.CodeFixExtensions.CodeFixContext-RegisterFsharpFix@108(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetCodeFixesAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)

Metadata

Metadata

Assignees

Labels

Area-LangService-CodeFixesCode fixes associated with diagnosticsBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions