ILSpy icon indicating copy to clipboard operation
ILSpy copied to clipboard

String `https://github.com/icsharpcode/ILSpy` should not be a part of xaml

Open CreateAndInject opened this issue 2 years ago • 1 comments

xaml.zip

DASConfigurator.g.resources/app.baml

        <toolkit:Wizard.BackButtonContent>
          <lex:LocExtension>
            <Ctor xmlns="https://github.com/icsharpcode/ILSpy">WizardPrevious</Ctor>
          </lex:LocExtension>
        </toolkit:Wizard.BackButtonContent>

CreateAndInject avatar Mar 20 '23 15:03 CreateAndInject

Diagnosis of this issue:

This issue is caused by a failure to resolve the correct dependency assembly in the BAML decompiler type system.

This error occurs in this function, which checks whether a given type is a valid markup extension. https://github.com/icsharpcode/ILSpy/blob/1b99486322ca7153edf70a336bb2d323157002dc/ILSpy.BamlDecompiler/Rewrite/MarkupExtensionRewritePass.cs#L116-L145 This code fails in this case as the BAML decompiler type system is built with only the assemblies references by the current module.

In the snippet posted above LocExtension is located in the WPFLocalizeExtension assembly which is directly referenced by DASConfigurator. LocExtension derives from NestedMarkupExtension from XAMLMarkupExtensions assembly. This assembly is not directly referenced by DASConfigurator and is thus NOT loaded into the type system.

When the function mentioned above is executed to determine whether LocExtension can be used as a markup extension, the type system resolves its base type to a UnknownType as NestedMarkupExtension and its defining assembly is not present in the TS. Due to this error in resolution, this check fails. If the NestedMarkupExtension type was resolved correctly the check would succeed as NestedMarkupExtension derived from MarkupExtension.

A potential solution would be to extend the scope of reference assemblies loaded into the BAML decompiler type system.

ElektroKill avatar Mar 26 '23 11:03 ElektroKill