CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

CsWinRT authoring unknown KeyNotFoundException

Open andrewleader opened this issue 2 years ago • 2 comments

Describe the bug

While trying to use CsWinRT authoring in our Notifications Toolkit library, I ran into a KeyNotFoundException when building. I'm not sure what type it's unhappy with.

The CsWinRT log ends with this...

attribute constructor: Windows.Foundation.Metadata.DefaultOverloadAttribute.DefaultOverloadAttribute()

atttribute # constructor arguments: 0

atttribute # named arguments: 0

found # constructors: 1

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

   at System.ThrowHelper.ThrowKeyNotFoundException()

   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)

   at Generator.WinRTTypeWriter.AddCustomAttributes(TypeDeclaration typeDeclaration, String interfaceName)

   at Generator.WinRTTypeWriter.FinalizeGeneration()

   at Generator.ComponentGenerator.Generate()

Version Info

CsWinRT 1.3.5, net6.0-windows10.0.19041

CsWinRT log: log.txt

andrewleader avatar Oct 27 '21 23:10 andrewleader

Eliminating the DefaultOverloadAttribute (and commenting out those duplicate methods) didn't improve anything, same KeyNotFoundException

Updated log log.txt :

andrewleader avatar Oct 28 '21 00:10 andrewleader

I've pinpointed the problem to some of our advanced classes that use [ComImport]/etc. Don't know specifically what causes it but removing all of those advanced files caused it to work. I'll report back with more when I know more about what specifically is breaking it.

andrewleader avatar Oct 28 '21 00:10 andrewleader