XamlX icon indicating copy to clipboard operation
XamlX copied to clipboard

ArgumentOutOfRange exception in ResolveContentPropertyTransformer.Transform

Open ds1709 opened this issue 11 months ago • 0 comments

There'e multiple scenarios when compilling axaml throws internal compiller error (ArgumentOutOfRangeException). This exception occures when you have in source axaml file any xml elements of types which has no Content property and has no any Add method, but contains any nested elements. I faced with this trying to add objects into DataGrid, but it reproduces for other object types.

How to Reproduce

Scenario 1 (DataGrid):

<DataGrid>
    <sys:Int32>1<sys:Int32>
</DataGrid>

Scenario 2 (Object):

<sys:Object>
    <sys:Int32>1<sys:Int32>
</sys:Object>

In both scenarios on compilling:

XamlTransformException: Internal compiler error: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index (ResolveContentPropertyTransformer) Line 37, position 6.

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at XamlX.Transform.Transformers.ResolveContentPropertyTransformer.Transform(AstTransformationContext context, IXamlAstNode node) in D:\Git\AvaloniaUI\Avalonia\src\Markup\Avalonia.Markup.Xaml.Loader\xamlil.github\src\XamlX\Transform\Transformers\ResolveContentPropertyTransformer.cs
   ... <truncated>

Expected behavior

Compilation error No Content property or any Add methods found for type <type name>.

Additional info

More detaile here

ds1709 avatar Mar 22 '24 09:03 ds1709