-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue for all possible XAML compiler warnings #13707
Comments
Duplicate property, two cases: Attribute + element: <Border Background="Blue">
<Border.Background>Red</Border.Background>
</Border> Double elements: <Border>
<Border.Background>Blue</Border.Background>
<Border.Background>Red</Border.Background>
</Border> Double attributes is already a XML parsing error. |
It would be nice to have dependency properties able to instantiate collections lazily instead so users don't have to know whether they should instantiate the collection or not. Currently we have two types:
I'll open a separate proposal to discuss that. |
|
Used |
Opt-in warnings for |
XAML compiled should detect following patterns: <TabControl>
<TabControl.ItemTemplate>
<DataTempalte>
<TabItem Header="{Binding Title}" /> <!-- WARNING: --> And recommend something like this (possibly, just a link to the documentation/samples): <TabControl ItemsSource="{Binding ...}">
<TabControl.Styles>
<Style Selector="TabItem">
<Setter Property="Header" Value="{Binding Title}"/>
</Style>
</TabControl.Styles>
</TabControl> |
Is it possible to add a warning when base type declaration in XAML and code behind does not match ? |
@Al-Dyachkov can you bring some example? If types of XAML and code behind are not compatible, there should already be an error (not even a warning). Unless I am missing something. ReactiveUserControl in code behind and UserControl in XAML should also be fine. |
xaml <reactiveUi:ReactiveUserControl x:TypeArguments="VM"
x:Class="View"
x:DataType="VM">
...
</reactiveUi:ReactiveUserControl> code behind public partial class View : UserControl
{
} This compiles and even works to some extent because ReactiveUserControl<T> is derived from UserControl, but without Reactive UI features like activation, because it is actually a UserControl. This is a minor issue that is usually fixed right away but would be nice to have a warning anyway. |
What do you think about pinning this issue so it's easy to find? |
I would suggest adding a warning when a DynamicResource is reassigned. I wasted a whole day troubleshooting a problem due to this. |
@workgroupengineering can you give an example? |
A third-party control defines within it a Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Dresses.Warehouse"
x:Class="My.App"
>
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Resources>
<x:Double x:Key="SmallIconSize">18</x:Double>
</Application.Resources>
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application> <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="My.Views.MainView"
x:ClassModifier="internal"
>
<UserContro.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- internally redefines the resource SmallIconSize 24 -->
<ResourceInclude Source="avares://third_party/third_party_Control.axaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserContro.Resources>
<!-- The size is 24 instead of the expected 16, this is because I don't know Third_party_Control.axaml redefines SmallIconSize. -->
<Rectangle Fill="Red"
Width="{DynamicResource SmallIconSize}"
Height="{DynamicResource SmallIconSize}"/>
</UserControl > |
Add Warning suppression il xaml like <!--#Suppress-Start: AVX11111 - Reason -->
...
<!--#Suppress-End: AVX11111-->
|
That's the exactly what a dynamic resource should do imo 🤔 |
but if I don't know that it was redefined by another library I will get unexpected behavior. It just needs to show a warning like SmallIconSize has been redefined in avares://third_party/third_party_Control.axaml |
Sounds as an expected possibility.
We currently don't have this information. As we don't store such metadata.
Yeah, we need something for that. |
yet another one (maybe) #15593 |
Add warning when local value override style selector <Window.Styles>
<Style Selector=":is(StackPanel) Rectangle.Go">
<Setter Property="Fill" Value="Red"/>
</Style>
<Style Selector=":is(StackPanel) Rectangle:not(.Go)">
<Setter Property="Fill" Value="Blue"/>
</Style>
</Window.Styles>
<StackPanel>
<Rectangle Width="10" Height="10" Fill="Green"/> <!-- Add warning this line -->
</StackPanel> |
As raised in #16755, If the class in the code-behind is Control and the XAML is UserControl, it causes an Internal Compiler Error in the XAML compiler, so this mistake can be serious (and very hard to diagnose). |
Any other ideas?
The text was updated successfully, but these errors were encountered: