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

AOT fails with Dictionary<T, U> in 1.6 Experimental #9710

Closed
veler opened this issue Jun 8, 2024 · 3 comments
Closed

AOT fails with Dictionary<T, U> in 1.6 Experimental #9710

veler opened this issue Jun 8, 2024 · 3 comments
Labels
area-AOT bug Something isn't working

Comments

@veler
Copy link

veler commented Jun 8, 2024

Describe the bug

In WinApp SDK 1.6 Experimental with AoT turned ON, build fails when using a property or method that returns a Dictionary with a strong type.

C:\repo\MyApp\MyApp\obj\x64\Release\net8.0-windows10.0.22621.0\win-x64\intermediatexaml\WinRT.SourceGenerator\Generator.WinRTAotSourceGenerator\WinRTGenericInstantiation.g.cs(1455,33,1455,53): error CS0234: The type or namespace name 'MyApp' does not exist in the namespace 'ABI' (are you missing an assembly reference?)

Steps to reproduce the bug

Project file:

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<OutputType>WinExe</OutputType>
		<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
		<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
		<RootNamespace>WinRTGenericMissing</RootNamespace>
		<ApplicationManifest>app.manifest</ApplicationManifest>
		<Platforms>x86;x64;ARM64</Platforms>
		<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
		<PublishProfile>win-$(Platform).pubxml</PublishProfile>
		<UseWinUI>true</UseWinUI>
		<EnableMsixTooling>true</EnableMsixTooling>
		<WindowsSdkPackageVersion>10.0.22621.35-preview</WindowsSdkPackageVersion>
		<PublishAot>true</PublishAot>
	</PropertyGroup>

	<ItemGroup>
		<Content Include="Assets\SplashScreen.scale-200.png" />
		<Content Include="Assets\LockScreenLogo.scale-200.png" />
		<Content Include="Assets\Square150x150Logo.scale-200.png" />
		<Content Include="Assets\Square44x44Logo.scale-200.png" />
		<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
		<Content Include="Assets\StoreLogo.png" />
		<Content Include="Assets\Wide310x150Logo.scale-200.png" />
	</ItemGroup>

	<ItemGroup>
		<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.0-prerelease.240602.1" />
		<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1" />
		<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240531000-experimental1" />
		<Manifest Include="$(ApplicationManifest)" />
	</ItemGroup>

	<!--
    Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
    Tools extension to be activated for this project even if the Windows App SDK Nuget
    package has not yet been restored.
  -->
	<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
		<ProjectCapability Include="Msix" />
	</ItemGroup>

	<!--
    Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
    Explorer "Package and Publish" context menu entry to be enabled for this project even if
    the Windows App SDK Nuget package has not yet been restored.
  -->
	<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
		<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
	</PropertyGroup>
</Project>

And a C# file:

public class LearningData { }

public sealed partial class MainWindow : Window
{
    // This does not build.
    private async Task<Dictionary<string, LearningData>> DoesNotBuild()
    {
    }
    
    // This does build however.    
    private async Task<Dictionary<string, int>> DoesNotBuild()
    {
    }
}

Expected behavior

Get it to build.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6 Experimental 1: 1.6.240531000-experimental1

Windows version

Windows 11 (22H2): Build 22621

Additional context

The issue seems to reproduce with Dictionary<T, U> along with IReadOnlyDictionary<T, U>, and probably many others. It's interesting that using a value type on U makes it work.

@veler veler added the bug Something isn't working label Jun 8, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jun 8, 2024
@codendone codendone added area-AOT and removed needs-triage Issue needs to be triaged by the area owners labels Jun 8, 2024
@Sergio0694
Copy link
Member

Don't have triage permissions here, but this should be moved to https://github.com/microsoft/CsWinRT.

@manodasanW
Copy link
Member

Dupe of microsoft/CsWinRT#1638

@Scottj1s
Copy link
Member

@veler thanks for reporting this. The issue has been fixed and will be available in the next preview release of the Microsoft.Windows.CsWinRT package.

cc: manodasanw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-AOT bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants