pascaleschbach / xf.bindableproperty Goto Github PK
View Code? Open in Web Editor NEWTurns your auto properties into Xamarin.Forms BindableProperties.
License: MIT License
Turns your auto properties into Xamarin.Forms BindableProperties.
License: MIT License
After updating Visual Studio a strange error message started to show up in my project.
I created a new Xamarin.Forms project to investigate and I found that whenever I implement Xamarin.Forms.BindableObject (or its superclass) , I cannot add any [Bindable] attributes.
public class MyClass : BindableObject
{
[Bindable]
public float MyProperty { get; set; }
}
Detailed error message:
Error Fody: An unhandled exception occurred:
Exception:
Failed to execute weaver C:\Users\Alari\.nuget\packages\xf.bindableproperty.fody\1.2.1\build\..\weaver\XF.BindableProperty.Fody.dll
Type:
System.Exception
StackTrace:
at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 202
at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 109
Source:
FodyIsolated
TargetSite:
Void ExecuteWeavers()
Could not load file or assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
Type:
System.IO.FileNotFoundException
StackTrace:
at BindableProperty.Weave()
at ModuleWeaver.Execute()
at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 174
Source:
XF.BindableProperty.Fody
TargetSite:
Void Weave()
Could not load file or assembly 'System.ValueTuple, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
Type:
System.IO.FileNotFoundException
XFBindablePropertyTest 1
I'm writing some test cases for this library before extending it for my internal usage. Right now if you try to run multiple tests, the tests are all failed except one with the error message like below
Member ** is declared in another module and needs to be imported
**: Usually one of these types.
However, they all pass if executed individually. The reason (I believe) is because the WeaverTypes
class is static so the TypeReference
s are imported from multiple assemblies when running
weavingTask.ExecuteTestRun("AssemblyToTestxX.dll")
In multiple test cases. I implemented a fix by making WeaverTypes
non-static and instantiate it as a member of ModuleWeaver
and reference it from there instead of globally. If you decide to write unit tests some day, be aware of that pitfall in your code.
When defining a string auto property I can do:
[Bindable]
public string Name { get; set; } = "John";
When I try to create a bindable property with a type anything other than a string
[Bindable]
int Age { get; set; } = 30;
I get the following error
System.TypeInitializationException: The type initializer for 'TestFody.Views.TestView' threw an exception. ---> System.InvalidProgramException: Invalid IL code in TestFody.Views.TestView:.cctor (): IL_0095: call 0x0a000034
To get it to work, I have to type
[Bindable(OnCreateValue = nameof(CreateAge))]
public int Age { get; set; }
private static object CreateAge(BindableObject bindable) => 30;
It's of course A LOT better than the alternative.
Since PropertyChanged.Fody seems to handle different types automatically, Im guessing it could be done here also.
Awesome package by the way! :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.