Coder Social home page Coder Social logo

catel.fody's Introduction

Catel

Name Badge
Chat Join the chat at https://gitter.im/catel/catel
Downloads NuGet downloads
NuGet stable version Version
NuGet unstable version Pre-release version
MyGet unstable version Pre-release version
Open Collective Backers on Open Collective Sponsors on Open Collective

Catel is an application development platform with the focus on MVVM (WPF, UWP, Xamarin.Android, Xamarin.iOS and Xamarin.Forms). The goal of Catel is to provide a complete set of modular functionality for Line of Business applications written in any .NET technology, from client to server.

Catel distinguishes itself by unique features to aid in the development of MVVM applications and server-side application development. Since Catel focuses on Line of Business applications, it provides professional support and excellent documentation which ensures a safe bet by professional companies and developers.

For documentation, please visit the documentation portal

Features and components

Below are a few features that are available in Catel.

Catel.Core

Catel.Core is the library you want to include in all your projects, whether you are writing a UI project or not. It contains lots of useful helper methods. The most important features are listed below:

  • Argument validation (e.g. Argument.IsNotNull(() => myArgument))
  • Caching
  • Data (ModelBase, PropertyBag, Validation)
  • IoC (ServiceLocator, TypeFactory)
  • Logging (LogManager, Log, several log listeners)
  • Messaging
  • Reflection (same reflection API for every supported platform)
  • Serialization (BinarySerializer, XmlSerializer and more)
  • Weak references (WeakEventListener)

And more....

Catel.MVVM

Catel.MVVM is the library you want to include when you are writing a UI project (e.g. WPF, UWP, Xamarin) and you want to use the MVVM pattern. Catel is the only MVVM library that has context-aware view and view-model creation, which can be used to solve the nested user controls problem.

The most important features are listed below:

  • Auditing
  • Collections (FastObservableCollection)
  • Commands (Command, TaskCommand, etc)
  • Converters (tons of converters out of the box)
  • Services
    • CameraService
    • LocationService
    • MessageService
    • NavigationService
    • OpenFileService
    • PleaseWaitService
    • SaveFileService
    • UIVisualizerService
  • View models
    • Automatic validation
    • Automatic mappings from model to view model
  • Views
    • DataWindow
    • UserControl
    • Window

Example code

Models

This model has automatic change notifications and validation.

public class Person : ValidatableModelBase
{
    public string FirstName { get; set; }

    public string LastName { get; set; }

    protected override void ValidateFields(List<IFieldValidationResult> validationResults)
    {
        if (string.IsNullOrWhitespace(FirstName))
        {
            validationResults.Add(FieldValidationResult.CreateError(nameof(FirstName), "First name is required"));
        }

        if (string.IsNullOrWhitespace(LastName))
        {
            validationResults.Add(FieldValidationResult.CreateError(nameof(LastName), "Last name is required"));
        }
    }    
}

View models

This is a view model with:

  • Automatic injection of the DataContext
  • Automatic mapping of properties & validation from model => view model
public class PersonViewModel : ViewModelBase
{
    public PersonViewModel(Person person)
    {
        Argument.IsNotNull(() => person);

        Person = person;
    }

    [Model]
    private Person Person { get; set; }

    [ViewModelToModel]
    public string FirstName { get; set; }

    [ViewModelToModel]
    public string LastName { get; set; }
}

How to contribute

Support on Open Collective

Please consider supporting Catel on Open Collective.

Translating

To add translations to Catel, the Multilingual App Toolkit (MAT) is required.

  1. Download the MAT Editor
  2. Open your specific language (or create it) in the MultilingualResources folder, e.g. ./src/Catel.MVVM/MultilingualResources/Catel.MVVM.nl.xlf
  3. Edit the xlf file and create a pull request (PR) with only this file

Building Catel

Prerequisites

Catel requires Visual Studio 2019 to compile successfully. You also need to ensure you have the following features installed:

Note that the .vsconfig in the src root should notify about missing components when opening the solution.

  • .NET desktop development
  • Universal Windows Platform development
  • Mobile development with .NET
  • .NET Core cross-platform development
  • Select the following components from Individual components
    • Windows 10 SDK (10.0.16299.0)
    • MSVC v141 and v142 (ARM, ARM64 and x64/x86)
    • C++ ATL v141 and v142 (ARM, ARM64 and x86 & x64) build tools
    • C++ MFC v141 and v142 (ARM, ARM64 and x86 & x64) build tools
  • Latest Version of .NET Core 3.0 Preview SDK
    • Ensure you enable Use previews of the .NET Core SDK under Tools -> Options -> Projects and Solutions -> .NET Core

Note that you should run these commands using powershell in the root of the repository.

Running a build

.\build.ps1 -target build

Running a build with unit tests

.\build.ps1 -target buildandtest

Running a build with local packages

Note that this assumes a local packages directory at C:\Source\_packages, which can be added to the NuGet feeds:

.\build.ps1 -target buildandpackagelocal

Apps using Catel

There are a lot of (both free & commercial) apps using Catel. This list provides a few examples that are built with Catel:

// todo: add wpf

// todo: add uwp

WPF components based on Catel

If you are planning on using WPF, there is a huge set (60+) of free open-source components available based on Catel. All these open source are developed by a company called WildGums (see https://www.wildgums.com) and provided to the community for free. The components are well maintained and being used in several commercial WPF applications.

For more information, see https://github.com/wildgums

Tools for Catel

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

catel.fody's People

Contributors

alexfdezsauco avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar geertvanhorrik avatar github-actions[bot] avatar gitter-badger avatar selvinpl avatar simoncropp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

catel.fody's Issues

"The weaver needs to add a NuGet reference" in build

Hello. Apologies if this is not the right place to post this - I haven't found any place to get help.
I updated the NuGet packages for my project and now I get:

Fody: Fody (version 2.0.2.0) Executing
MSBUILD : error : Fody: The weaver assembly 'Catel.Fody, Version=2.15.0.0, Culture=neutral, PublicKeyToken=null' references an out of date version of Mono.Cecil.dll (cecilReference.Version). At least version 0.10 is expected. The weaver needs to add a NuGet reference to FodyCecil version 2.0.2.0.

... is this something I can fix on my end ? If so how? Thanks.

CatelFodyNullException with IEquatable implemented in another assembly

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

Component

Catel.Fody / Fody

Version of Library

Tested with
Catel.Core 5.12.9 + Catel.Fody v4.4.0.0 + Fody 6.2.4
Catel.Core 5.12.10 + Catel.Fody v4.4.0.0 + Fody 6.2.4
Catel.Core 5.12.10 + Catel.Fody v4.5.0.0 + Fody 6.2.4
Catel.Core 5.12.10 + Catel.Fody v4.5.0.0 + Fody 6.3.0

Version of OS(s) listed above with issue

win 10, net472

Steps to Reproduce

  1. Create a generic class (i.e. KeyValuePair<T,V>) in one project & implement two interfaces involving the type parameters- one of which (I'm pretty sure) should be the IEquatable
  2. Create a concrete class in a second assembly, erasing the type parameters (e.g. MyPair)
  3. Host the extended object in a class extending ModelBase (in the second assembly).

Expected Behavior

2> Fody/Catel: MyModel - adding static constructor
2> Fody/Catel: MyModel - added static constructor
2> Fody/Catel: MyPair - adding GetValue call
2> Fody/Catel: MyPair - adding SetValue call
Property change

Actual Behavior

The build fails with a NullException
Fody/Catel: Object reference not set to an instance of an object. CatelFodyNullException

Having either the KeyValuePair (base class) created in the local assembly, or removing one of the interfaces of the base class resolves the issue..

Here is a simple reproduction (using the current latest versions of each library)

Weave calculated property notifications as if-else-if, not consecutive ifs

Summary

change the way calculated properties are weaved to short-circuit using nested ifs
currently ,
Weaving readonly properties will place multiple IF statements in OnPropertyChanged
like so :

if (e.PropertyName.Equals("X"))
{
	base.RaisePropertyChanged("Y");
}
if (e.PropertyName.Equals("Z"))
{
	base.RaisePropertyChanged("Y");
}
if (e.PropertyName.Equals("H"))
{
	base.RaisePropertyChanged("B");
}
if (e.PropertyName.Equals("A"))
{
	base.RaisePropertyChanged("C");
}

API Changes

make the method short-circuit if it finds a suitable match, e.g.

if (e.PropertyName.Equals("X"))
{
	base.RaisePropertyChanged("Y");
}
else if (e.PropertyName.Equals("Z"))
{
	base.RaisePropertyChanged("Y");
}
else if (e.PropertyName.Equals("H"))
{
	base.RaisePropertyChanged("B");
}
else if (e.PropertyName.Equals("A"))
{
	base.RaisePropertyChanged("C");
}

Intended Use Case

This way it won't have to check every possible property name when it finds it early

Init only properties are not being weaved

Init only properties are not being weaved, causing this code to have runtime issues:

[Model]
[Expose(nameof(MyModel.SubProperty))]
public MyModel ModelProperty { get; }

Since the property does not get weaved, the Expose will not be handled either and causing runtime issues.

The solution is to always weaver such properties when decorated with the Model attribute.

Catel.Fody Fails to weave properties that are referenced across multiple projects

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

Component

Catel.Fody

Version of Library

  • Catel.Fody: 4.6.0
  • Catel.Core: 5.12.11
  • Catel.MVVM: 5.2.11

Version of OS(s) listed above with issue

Windows 10 20H2

Steps to Reproduce

Sample solution has been attached (WpfApp2.zip)

Expected Behavior

Property weaving should complete successfully as designed in release 4.5.0

Actual Behavior

Numerous exceptions are thrown:

1>MSBUILD : error : Fody/Catel: Type 'System.CodeDom.Compiler.GeneratedCodeAttribute' cannot be found, please report this bug
1>MSBUILD : error : Fody/Catel: Type 'System.Runtime.CompilerServices.CompilerGeneratedAttribute' cannot be found, please report this bug
1>MSBUILD : error : Fody/Catel: Type 'System.Diagnostics.DebuggerNonUserCodeAttribute' cannot be found, please report this bug
1>MSBUILD : error : Fody/Catel: Type 'System.ComponentModel.PropertyChangedEventArgs' cannot be found, please report this bug
1>MSBUILD : error : Fody/Catel: Type 'Void' cannot be found, please report this bug
1>MSBUILD : error : Fody/Catel: 		Failed to handle property 'PersonModel.BirthDate'

Additional Notes

Rolling back to release 4.5.0 is the current workaround. It appears the issue may have been introduced as a side effect of #274 (or possibly #291)

Method OnPropertyChanged for exposed property is called with old value

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

Component

ViewModel

Version of Library

Catel.MVVM 6.0.0-alpha1271
Catel.Fody 4.9.0

Version of OS(s) listed above with issue

Windows 11

Steps to Reproduce

  1. Create model:
public class AppSettingsModel : ViewModelBase
{
  public string SelectedThemeName { get; set; }
}
  1. Create ViewModel and OnPropertyChangedMethod:
public class AppSettingsViewModel : ViewModelBase
{
    [Model]
    [Expose("SelectedThemeName")]
    public AppSettingsModel AppSettings { get; set; }
   
    public AppSettingsViewModel(AppSettingsModel appSettings)
    {
       AppSettings = appSettings;
    }

    private void OnSelectedThemeNameChanged()
    {
       //  This method is called when AppSettings.SelectedThemeName have old value, not the current one
    }
}
  1. Change property (for example, by binding in the view)

Expected Behavior

OnPropertyChanged should be called after property gets its new value.

Actual Behavior

OnPropertyChanged is called before the property value changes.
But if we get the value of property using dynamic object it will be correct. For example:

    private void OnSelectedThemeNameChanged()
    {
      var oldValue = AppSettings.SelectedThemeName; // Old value 
      dynamic thisDynamic = this;
      var theme = thisDynamic.SelectedThemeName;  // Correct value.
    }

Also if we expose property as below:

public class AppSettingsViewModel : ViewModelBase
{
    [Model]
    public AppSettingsModel AppSettings { get; set; }

    [ViewModelToModel("AppSettings")]
    public string SelectedThemeName { get; set; }

OnSelectedThemeNameChanged works correctly and has the current value.

ObservableObject setters should check for equality before assigning

Instead of this:

        public string ExistingProperty
        {
            get => _existingProperty;
            set
            {
                _existingProperty = value;
                RaisePropertyChanged(nameof(ExistingProperty));
            }
        }

into:

        public string ExistingProperty
        {
            get => _existingProperty;
            set
            {
                if (_existingProperty == value)
                {
                    return;
                }

                _existingProperty = value;
                RaisePropertyChanged(nameof(ExistingProperty));
            }
        }

ViewModelBase derived classes with own SetValue method generating wrong code

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

  • [x ] WPF
  • UWP
  • iOS
  • Android
  • [ x] .NET Standard
  • .NET Core

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. Use code llike this and check what it generate (problem is VM.SetValue of course)
    public class VM : ViewModelBase
    {
        [Model]
        public Test Test { get; set; }
        [ViewModelToModel]
        public string Prop { get; set; }

        public void SetValue(string a)
        {

        }
    }

    public class Test
    {
        public string Prop { get; set; }
    }

Expected Behavior

It should generate right code

Actual Behavior

it generates gibberish:

	[Model]
	public Test Test
	{
		[CompilerGenerated]
		get
		{
			return GetValue<Test>(TestProperty);
		}
		[CompilerGenerated]
		set
		{
			//IL_000d: Expected O, but got I4
			_ = TestProperty;
			((ViewModelBase)(object)value).SetValue<!!0, !!1, !!2>((!!0)1);
		}
	}

	[ViewModelToModel("", "")]
	public string Prop
	{
		[CompilerGenerated]
		get
		{
			return GetValue<string>(PropProperty);
		}
		[CompilerGenerated]
		set
		{
			//IL_000d: Expected O, but got I4
			_ = PropProperty;
			((ViewModelBase)(object)value).SetValue<!!0, !!1, !!2>((!!0)1);
		}
	}

which finally leads to System.MissingMethodException: 'Method not found: 'Catel.Data.PropertyData Catel.MVVM.ViewModelBase.SetValue(!!0)'.' with code

new VM().Test = new Test { Prop = "Whatever"};

Update to Fody Version 2

Fody Version 2 is out and you will need to do an update for your addin to be usable with it

Specifically:

  • Update to the newest Fody.Cecil nuget
  • Change the min dependency ranged for Fody to be at least 2.0

Please ping me if u need help

Calculated properties not working in UWP app

For a repro, see https://github.com/byrialsen/CatelTest

The reason is that CompilerGenerated attribute is not found for WinRT compilations. This causes the generated OnPropertyChanged not to be marked as compiler generated. For the next property that requires auto-change notifications, the method will be ignored because it's not compiler generated (non-compiler generated methods are untouched to prevent unwanted side-effects).

Object reference not set to an instance of an object

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)

  • [x ] WPF
  • UWP
  • iOS
  • Android
  • .NET Standard
  • .NET Core

Component

Catel/Fody

Version of Library

Custom build from latest release in the case of orchestra (Mahapps + fluent, instead of one or the other) otherwise standard latest release.

Version of OS(s) listed above with issue

All the OS's

Steps to Reproduce

  1. Fork/Clone Wolvenkit at : https://github.com/WolvenKit/Wolvenkit (DEV BRANCH)
  2. regular steps to open a project / restore nugets.
  3. build&run. get error.

Expected Behavior

Press green button once to build and run the debug.

Actual Behavior

Need to press green button twice always.

OnPropertyChanged is called twice if we use the ViewModelToModel attribute

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

Component

ViewModel

Version of Library

Catel.Core 6.0.1
Catel.Fody 4.9.0

Version of OS(s) listed above with issue

Windows 11

Steps to Reproduce

Here is test code:

  // Simple model class
  public class TestModel : ObservableObject
  {
    private int _coutner;

    public object Property { get; set; }

    private void OnPropertyChanged()
    {
      _coutner++;
      Debug.WriteLine($"Property changed: {Property} {_coutner}");
    }
  }

  // ViewModel 
  public class MyDerivedViewModel : ViewModelBase
  {
    [Model]
    public TestModel Model { get; set; }

    [ViewModelToModel]
    public object Property { get; set; }

    public MyDerivedViewModel()
    {
      Model = new TestModel();
      Model.Property = "test";
    }
  }

We have TestModel object and a ViewModel that uses it. ViewModel exposes the property from the TestModel object by using the attribute [ViewModelToModel].

Expected Behavior

after changing the property function OnPropertyChanged() should be called, one time.

Actual Behavior

OnPropertyChanged() is called twice. And output from creating MyDerivedViewModel is:
Property changed: test 1
Property changed: test 2

If instead of " Model.Property = "test";" we will use the code Property = "test"; OnPropertyChanged is called once

Property on derived interface

Steps to reproduce

  1. Create an interface IChild implementing an other interface IParent
  2. Create a ViewModel and a model property type IChild
  3. Expose a property in IParent.

Platform: VisualStudio 2013
.NET version: .NET4.5.2

Expected behaviour

As on the classes

Actual behaviour

We have an error :
Fody/Catel : The object reference is not defined ...

Getter only property to be weaving.

IF IT IS A NEW FEATURE REQUEST, INCLUDE THIS PART:

Feature description

If it is an auto property, weaving should be good.

[ViewModelToModel(nameof(Source), nameof(Name), Mode = ViewModelToModelMode.OneWay)]
public override string DisplayName { get; }

It can work when the above code exists.

Can you guide me how to use Crypto Obfuscator For .Net for obfuscated encryption? Before Costura.Fody works ?

How to perform obfuscation before packaging

Crypto Obfuscator For .Net

I have searched a lot of information and it seems that I have not found a suitable solution

Can you guide me how to use Crypto Obfuscator For .Net for obfuscated encryption? Before Costura.Fody works

  • ths very much....

Part 2 of Object Reference not set to an instance of an object.

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

Component

What component is this issue occurring in?
Catel/Fody

Version of Library

Latest Prerelease as advised.

Version of OS(s) listed above with issue

Mostly W10 (I am not sure if we have users on W7)

Steps to Reproduce

  1. Fork /clone Wolvenkit
  2. Make some changes. launch
  3. result

Expected Behavior

No Fody errors

Actual Behavior

The error still pops when making changes in the project and then building it again.

Rerunning build after this will make it launch without issues.

During Github build this issue is maybe a bit clearer to see :
https://github.com/WolvenKit/Wolvenkit/runs/1914026534#step:6:1094

Building with WeaveArguments in Debug fails with 2.17.0

Hi Geert,

I just have updated Catel.Fody from v2.14.0 to v2.17.0 (Fody from v1.29.4 to v2.1.0) and got this error:

[...]
2: Fody/Catel: Finished 'Catel' in 1867ms
2: Fody: Adding weaving info
2: Fody: Finished in 1ms
2: Fody: Writing assembly to 'D:_git\K3PO\src\K3PO.Core\obj\x64\Debug\K3PO.Core.dll'.
2: Error (0,0): Fody: An unhandled exception occurred:
Exception:
Value does not fall within the expected range.
StackTrace:
at Mono.Cecil.Pdb.ISymUnmanagedWriter2.DefineLocalVariable2(String name, Int32 attributes, Int32 sigToken, Int32 addrKind, Int32 addr1, Int32 addr2, Int32 addr3, Int32 startOffset, Int32 endOffset)
at Mono.Cecil.Pdb.NativePdbWriter.DefineScope(ScopeDebugInformation scope, MethodDebugInformation info, MetadataToken& import_parent)
at Mono.Cecil.Pdb.NativePdbWriter.Write(MethodDebugInformation info)
at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody(MethodDefinition method)
at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypes()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.MetadataBuilder.BuildMetadata()
at Mono.Cecil.ModuleWriter.<>c.b__2_0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func3 read) at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at InnerWeaver.WriteModule() in C:\projects\fody\FodyIsolated\ModuleWriter.cs:line 18
at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 89
Source:
Mono.Cecil.Pdb
TargetSite:
Void DefineLocalVariable2(System.String, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)
2: Fody: Finished Fody 2525ms.

I am in the beginning of finding the problem but I do not really know how und where to look.
But if I remove Catel from FodyWeavers it builds and no error occurs.
I also found you issue Fody/Fody#312 but this one is different.

Perhaps you have any idea on how I can get more info on this?

Attribute to suppress message

Add attribute to suppress message

Method 'XXXX' matches automatic change method name but has parameters and will not be used as automatic change callback. Rename the method to remove this warning or remove parameters to use as automatic callback method.
fx I had class

class SomeBaseViewModel<T> : ViewModelBase
{
	public T SelectedItem { get; set; }

	protected virtual void OnSelectedItemChanged(T item) { }

	[SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Used by generator")]
	private void OnSelectedItemChanged()
	{
		OnSelectedItemChanged(SelectedItem);
	}
}

I would like to my build be silent

resolution:

add some code here

var callbackReferences = (from method in declaringType.Methods

to not take method with some attribute into account

Invalid IL is being generated for argument null expressions

This code causes invalid IL:

        protected override void UpdateCellContainer(Tile cellContainer, Cell cell)
        {
            Argument.IsNotNull(() => cell);

            var border = (TiledBorder) cellContainer;

            border.BackgroundColor = DataGridCellStyleColors.HeaderBackground;
        }

Allow visibility of generated properties to be customized

By default the properties are public, but this might hinder assemblies with obfuscation. By allowing this to be customized (should still default to public).

Property name could be:

"GeneratedPropertyDataAccessibility" (default is Public)

Catel.Fody doesn't weave the virtual properties correctly

Catel.Fody.Repro.zip

  • .NET Core

Component

Catel.Fody weaving properties

Version of Library

4.5.0

Version of OS(s) listed above with issue

win 10

Steps to Reproduce

use the attached repro.

Expected Behavior

properties declared as virtual should also be included in OnPropertyChanged if they have been used in a calculation property.

Actual Behavior

only not virtual properties will be included in OnPropertyChanged

Reference to ExposeAttribute not found.

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

Unused argument check causes invalid IL

Steps to reproduce

  1. Enable PEVerify on Fody
  2. Use this code.
        public static void SetIsToolTipsEnabled(this DataGridSettings settings, bool isToolTipsEnabled, DataGrid dataGrid)
        {
            Argument.IsNotNull(() => settings);

            var rowToolTipExtension = dataGrid.Extensions.FirstOrDefault(x => x is RowToolTipsExtension) as RowToolTipsExtension;
            if (rowToolTipExtension == null)
            {
                return;
            }

            rowToolTipExtension.EnableToolTips = isToolTipsEnabled;
        }

Platform:
.NET version:

Expected behaviour

Valid IL

Actual behaviour

Invalid IL

BadImageFormatException with Expose - weaver cannot resolve type of property

I'm not sure if it's bug in Catel.Fody or Fody/Mono itself but I'm getting

BadImageFormatException: Próbowano załadować program w niepoprawnym formacie.

with code

namespace CatelFodyBug
{
    using Catel.Fody;
    using Catel.MVVM;
    using System.Collections.Generic;

    public class TestViewModel : ViewModelBase
    {
        [Model]
        [Expose("ID")]
        public Model Model { get; set; }

        public static void Main(string[] args)
        {
            var vm = new TestViewModel();
        }
    }

    public class Model : BaseModel<Model>
    {
        
    }

    public class BaseModel<T> : EntityBaseWithID<int, T> where T: BaseModel<T>
    {

    }

    public class EntityBaseWithID<T, S>  where S : EntityBaseWithID<T, S>
    {
        public T ID { get; set; }

        //this is why I'm using S
        public override bool Equals(object other)
        {
            if (other is S n)
                return n.ID.Equals(ID);
            return false;
        }

        //irrelevant for this example
        public override int GetHashCode()
        {
            var hashCode = 509650306;
            hashCode = hashCode * -1521134295 + EqualityComparer<T>.Default.GetHashCode(ID);
            hashCode = hashCode * -1521134295 + GetType().GetHashCode();
            return hashCode;
        }
    }
}

obviously it's because generated code is wrong

public static readonly Catel.Data.PropertyData IDProperty = Catel.Data.ModelBase.RegisterProperty("ID", typeof(!0));
	public !0 ID
	{
		get..
		set..
	}

seems like weaver can't resolve generic type

Too many instances are being logged for the LogManager weaver

Output:

Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'
Fody/Catel: Weaving auto log to specific log for 'Prefix.Controls.DataGrid'

1 time is sufficient ;-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.