Skip to content
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

[regression/8.0.0-preview.6.8686] Static extension can't resolve nested class references from class libraries #16293

Closed
mavispuford opened this issue Jul 21, 2023 · 1 comment · Fixed by #16841
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 i/regression This issue described a confirmed regression on a currently supported version platform/android 🤖 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@mavispuford
Copy link

mavispuford commented Jul 21, 2023

Description

When referencing nested static values from a class library in Xaml using the StaticExtension, Visual Studio complains about being unable to resolve the type:

Error	XFC0000	Cannot resolve type "clr-namespace:StaticExtensionApp.ClassLibrary;assembly=StaticExtensionApp.ClassLibrary:LibraryConstants+LibraryIconCodes".	StaticExtensionApp	C:\Users\bross\source\repos\StaticExtensionApp\StaticExtensionApp\MainPage.xaml	47	

Here's my dotnet workload list output:

Installed Workload Id      Manifest Version                            Installation Source
-----------------------------------------------------------------------------------------------------------
maui-ios                   8.0.0-preview.6.8686/8.0.100-preview.6      VS 17.6.33829.357, VS 17.7.33913.275
maui-android               8.0.0-preview.6.8686/8.0.100-preview.6      VS 17.6.33829.357, VS 17.7.33913.275
maccatalyst                16.4.8646-net8-p6/8.0.100-preview.6         VS 17.6.33829.357, VS 17.7.33913.275
maui-windows               8.0.0-preview.6.8686/8.0.100-preview.6      VS 17.6.33829.357, VS 17.7.33913.275
maui-maccatalyst           8.0.0-preview.6.8686/8.0.100-preview.6      VS 17.6.33829.357, VS 17.7.33913.275
ios                        16.4.8646-net8-p6/8.0.100-preview.6         VS 17.6.33829.357, VS 17.7.33913.275
android                    34.0.0-preview.6.359/8.0.100-preview.6      VS 17.6.33829.357, VS 17.7.33913.275

Steps to Reproduce

  1. Create a new .NET MAUI app
  2. Create an additional class library project within your solution
  3. Create a static class with another nested static class inside which has a constant, like this:
public static class LibraryConstants
{
    public static class LibraryIconCodes
    {
        public const string LibraryIconCode = nameof(LibraryIconCode);
    }
}
  1. Reference the constant in a page, like this:
        <Label FontSize="18">
            <Label.FormattedText>
                <FormattedString>
                    <Span Text="Library icon code value: " />
                    <Span Text="{x:Static library:LibraryConstants+LibraryIconCodes.LibraryIconCode}" />
                </FormattedString>
            </Label.FormattedText>
        </Label>
  1. Attempt to build and run the app

See public repo for different constant reference combinations

Link to public reproduction project repository

https://github.com/mavispuford/StaticExtensionsAppIssue

Version with bug

8.0.0-preview.6.8686

Last version that worked well

7.0.86

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

Android 13, Windows 10.0.19044 Build 19044

Did you find any workaround?

No

Relevant log output

No response

@mavispuford mavispuford added the t/bug Something isn't working label Jul 21, 2023
@samhouts samhouts added the i/regression This issue described a confirmed regression on a currently supported version label Aug 2, 2023
@samhouts samhouts changed the title [.NET 8 Preview 6] Static extension can't resolve nested class references from class libraries [regression/8.0.0-preview.6.8686] Static extension can't resolve nested class references from class libraries Aug 2, 2023
@samhouts samhouts added this to the .NET 8 GA milestone Aug 2, 2023
@samhouts samhouts added the area-xaml XAML, CSS, Triggers, Behaviors label Aug 2, 2023
@AnnYang01
Copy link

AnnYang01 commented Aug 10, 2023

Verified this on Visual Studio Enterprise 17.8.0 Preview 1.0, This issue repro on .NET 8.0 with below Project:
MauiApp17.zip
SDK Version: 8.0.100-preview.7.23376.3
image

@AnnYang01 AnnYang01 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Aug 10, 2023
@pjcollins pjcollins self-assigned this Aug 17, 2023
pjcollins added a commit to pjcollins/maui that referenced this issue Aug 17, 2023
Fixes: dotnet#16293
Context: dotnet@db74ff7

The `XamlC` task was failing to resolve public nested types from a class
library.  Fix this by updating the `IsPublicOrVisibleInternal` checks
added in commit db74ff7 to also accept public nested types.
pjcollins added a commit to pjcollins/maui that referenced this issue Aug 17, 2023
Fixes: dotnet#16293
Context: dotnet@db74ff7

The `XamlC` task was failing to resolve public nested types from a class
library.  Fix this by updating the `IsPublicOrVisibleInternal` checks
added in commit db74ff7 to also accept public nested types.
@pjcollins pjcollins moved this from Todo to In Progress in MAUI SDK Ongoing Aug 17, 2023
pjcollins added a commit to pjcollins/maui that referenced this issue Aug 18, 2023
Fixes: dotnet#16293
Context: dotnet@db74ff7

The `XamlC` task was failing to resolve public nested types from a class
library.  Fix this by updating the `IsPublicOrVisibleInternal` checks
added in commit db74ff7 to also accept public nested types.
rmarinho pushed a commit that referenced this issue Aug 21, 2023
Fixes: #16293
Context: db74ff7

The `XamlC` task was failing to resolve public nested types from a class
library.  Fix this by updating the `IsPublicOrVisibleInternal` checks
added in commit db74ff7 to also accept public nested types.
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Aug 21, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 i/regression This issue described a confirmed regression on a currently supported version platform/android 🤖 platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants