Catel/Catel.Fody

Reference to ExposeAttribute not found.

Closed this issue · 7 comments

IF YOU DON'T ANSWER THIS TEMPLATE - THE BOT WILL AUTOMATICALLY CLOSE YOUR ISSUE!

Please check all of the platforms you are having the issue on (if platform is not listed, it is not supported)

  • WPF
  • UWP
  • iOS
  • Android
  • .NET Standard
  • .NET Core 6.0

Component

What component is this issue occurring in?
Catel.Fody

Version of Library

4.7.0

Version of OS(s) listed above with issue

Steps to Reproduce

  1. Create new .net core WPF project with .net 6.0
  2. Add Catel.Fody
  3. Use ExposeAttribute

Expected Behavior

Reference should be found and property should be weaved.

Actual Behavior

Reference is not found. Repro can be found here: https://github.com/pascalgross/FodyNet6

I don't see a reference to Fody itself? I think it's explicitly required to run the weavers.

Fody itself is referenced by Catel.Fody - at least that's what the package manager says.
Adding Fody manually does not help.

And even if Fody was not there, shouldn't be the ExposeAttribute be available anyways?

The expose attribute is defined in Catel.Fody.Attributes. Since this reference is private, it cannot be found at runtime. Catel.Fody will rewrite the code into more optimized code for you.

The fact that the reference is still being expected is a hint to me that Fody is not correctly running. Can you check the output to see if Fody and the Catel.Fody weaver are running correctly?

Sorry for the late response, I didn't get informed about your reply.

I'm unable to check the output because my application is not compiling as the reference to the ExposeAttribute is missing.
Visual Studio / the compiler should find Catel.Fody.Attributes/PropertyAttributes/ExposeAttribute.cs, shouldn't it?
At least if Catel.Fody is installed correctly.

I've tried to solve the problem, but I'm unable.
Catel.Fody Nuget Package is installed, but there is no Catel.Fody namespace in the Objectbrowser.

image
image

I used this project setup on your repro:

	<ItemGroup>
		<PackageReference Include="Catel.Core" Version="5.12.22" />
		<PackageReference Include="Catel.Fody" Version="4.7.0" PrivateAssets="All" />
		<PackageReference Include="Catel.MVVM" Version="5.12.22" />
		<PackageReference Include="Fody" Version="6.6.3">
		  <PrivateAssets>all</PrivateAssets>
		  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
		</PackageReference>
	</ItemGroup>

VS hinted:

image

Then updated FodyWeavers according to the warnings:

<Weavers VerifyAssembly="true" VerifyIgnoreCodes="0x80131869" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
  <Catel />
</Weavers>

Then fixed the startup uri in App.xaml:

StartupUri="/Views/MainWindow.xaml"

Finally added an initial user in the MainWindowViewModel ctor:

            Person = new Person
            {
                Name = "test"
            };

And it's all working for me.

Thanks, with the posted project setup, everythink is working as expected.
I don't really know, where the difference is to the auto-generated one:

<ItemGroup>
    <PackageReference Include="Catel.Core" Version="5.12.22" />
    <PackageReference Include="Catel.Fody" Version="4.7.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Catel.MVVM" Version="5.12.22" />
</ItemGroup>