Skip to content

"The Name 'XXX' has already been defined" build error occurs if ControlTemplate has visual element and VisualState with the same names #350

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

Closed
pavelovcharov opened this issue Feb 13, 2019 · 2 comments
Assignees
Labels
Bug Product bug (most likely) Design Discussion Ongoing discussion about design without consensus
Milestone

Comments

@pavelovcharov
Copy link

  • .NET Core Version: 3.0.100-preview-010184
  • Windows version: 1809 (17763.253)
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Problem description:
Build error occurs if ControlTemplate contains a visual element and VisualState with the same names

Actual behavior:
Build error "MC4101: The Name 'Normal' has already been defined. Names must be unique." occurs

Expected behavior:
No build errors

Minimal repro:
Create new .Net Core 3 wpf project, add the following ControlTemplate

    <Window.Resources>
        <ControlTemplate TargetType="Button" x:Key="buttonStyle">
            <Border x:Name="Normal">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="TestGroup">
                        <VisualState x:Name="Normal" />
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
            </Border>
        </ControlTemplate>
    </Window.Resources>

and try to build the project.

@stevenbrix
Copy link
Contributor

stevenbrix commented Feb 13, 2019

Thanks @pavelovcharov for filing this issue! This is interesting, in a .NET Framework WPF app, you see an intellisense error, and an error shows up in the ErrorsList, but doesn't cause your build to error. The UWP Xaml Compiler also treats this as an error condition as well, and your build will fail. The build error does seem like correct behavior, as the names would collide.

@ryalanms i'm assigning this to you. i'd imagine we should make sure this doesn't cause errors so that porting from .NET Framework -> .NET Core is as easy as possible. however, we should continue having discussions so that these behaviors are consistent and both UWP and WPF behave the same

@stevenbrix stevenbrix added Bug Product bug (most likely) Design Discussion Ongoing discussion about design without consensus labels Feb 13, 2019
@vatsan-madhavan vatsan-madhavan added this to the 3.0 milestone Mar 13, 2019
@ryalanms
Copy link
Member

This difference was due to a bug in BamlMapTable.

ryalanms added a commit that referenced this issue Apr 12, 2019
Move KnownAssemblyInfoRecord initialization out of BamlMapTable's static constructor to its constructor. (Fixes #378, #350)
@ghost ghost locked as resolved and limited conversation to collaborators Apr 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Product bug (most likely) Design Discussion Ongoing discussion about design without consensus
Projects
None yet
Development

No branches or pull requests

4 participants