XAML Serialization / Type not found - Help needed ! - wpf

No matching constructor found on type 'XYZ'. You can use the Arguments or FactoryMethod directives to construct this type.
I serialized a usercontrol. It was giving no error and successfully completed but on Deserialize, i got above exception.
The constructor of type(s) require arguments, it can't be null. So, plz help me to resolve this error.

you should try following the advice of this article, which describes in detail how you go about creating custom types that can be (de)serialized with XamlWriter and XamlReader.
You may also want to look at the explanation of what the Arguments and FactoryMethod directives do.

Related

Using Flink with thrift

I'm seeing some logs within my flink app with respect to my thrift classes:
2020-06-01 14:31:28 INFO TypeExtractor:1885 - Class class com.test.TestStruct contains custom serialization methods we do not call, so it cannot be used as a POJO type and must be processed as GenericType. Please read the Flink documentation on "Data Types & Serialization" for details of the effect on performance.
So I followed the instructions here:
https://flink.apache.org/news/2020/04/15/flink-serialization-tuning-vol-1.html#apache-thrift-via-kryo
And I did that for the thrift of TestStruct along with all the thrift structs within that. ( I've skipped over named types though ).
Also the thrift code that got generated is in Java whereas the flink app is written using scala.
How would I make that error disappear? Because I'm getting another bug where if I pass my dataStream to convert into that TestStruct, some fields are missing. I suspect this is due to serialization issues?
Actually, as of now, you can't get rid of this warning, but it is also not a problem for the following reason:
The warning basically just says that Flink's type system is not using any of its internal serializers but will instead treat the type as a "generic type" which means, it is serialized via Kryo. If you followed my blog post on this, this is exactly what you want: use Kryo to serialize via Thrift. You could use a debugger to set a breakpoint into TBaseSerializer to verify that Thrift is being used.
As for the missing fields, I would suspect that this happens during the conversion into your TestStruct in your (flat)map operator and maybe not in the serialization that is used to pass this struct to the next operator. You should verify where these fields get missing - if you have this reproducible, a breakpoint in the debugger of your favourite IDE should help you find the cause.

what is a target object in spring AOP

I am beginner to spring aop and i am going through spring aop documentation to understand the concepts but failed to understand 'target object'.
the documentation says target object is the "object being advised by one or more aspects. Also referred to as the advised object".
what is the meaning of being advised by one or more aspects here? can anyone explain me what is target object in Lyman terms as i am still a beginner.
For a simple explanation of some basic AOP terms please refer to my other answer. Please read that one first before continuing to read here.
So the target object is the (Java or Spring) component to which you want to add new behaviour, usually a cross-cutting concern, i.e. some behaviour that is to be applied to many classes in your code base.
An aspect is a class in which you implement that cross-cutting concern and also determine where and how to apply it. The where is defined by a pointcut, some kind of search expression finding the relevant parts of your code base to apply the behaviour to. The how is implemented in an aspect method called an advice.
So when we say that an aspect advises an object, it means that it adds (cross-cutting) behaviour to it without changing the class itself.
In Spring AOP this is mostly method interception, i.e. doing something before or after a method executes.
In the more powerful AspectJ you can also intercept changes of member variables and constructor execution. Furthermore you can change the class structure itself by adding new members or methods or making the target class implement an interface etc.
Is it possible to define multiple targets like below:
#Before(value = "com.test.createUpdateDeletePointCut() && (target(com.testlab.A) || target(com.testlab.B))")

How to get expression evaluation warnings from Angular

Is there any way to tell angular to show some Error or Warning about failed expressions? especially missing methods?
The reason I am asking this is that quite often angular would just break with no explanation, the reason could be that you have some object on the scope that used to have a getAllItems() method and someone decided to change it to getItems().
It would be very helpful if there was a way to get some form of a report that says that some expression e.g. user.messages.getAllItems().length failed to evaluate/parse/whatever because null has no length property or if they can say because user.messsages does not have a getAllItems method...
I am well aware that it is by design that angular expressions fail silently, but a way to get a report of said silent failures could prove to be very valuable.

How do I get Autofac delegate factories to work with obfuscation?

We're updating code to use Autofac. We'd like to use custom delegate types to define factories instead of Func's. But we also use an obfuscator, which renames parameters. We'd like to tell the Autofac container to match by type instead of name as it does with Func's. Is this possible?
On the official documentation of Autofac, you have this information
By default, Autofac matches the parameters of the delegate to the parameters of the constructor by name. If you use the generic Func types, Autofac will switch to matching parameters by type.
http://docs.autofac.org/en/latest/advanced/delegate-factories.html
Could you customize the obfuscator to use the same name for the parameter name of the delegate and the constructor?
As mentioned, the way to do it right now is to use Func. Even if it were possible with just delegate factories, Autofac won't know what to do when there are two parameters of the same type. Here's my answer to a very similar question.
Thanks guys. We ended up creating a custom registration source using Autofac's source as a guide. In our testing, if there are two parameters of the same type, it appears to fall back to order.

Error handling in custom directive

I am currently build a set of directives that we will be shipping to customer to use.
Now some of the directives has got required parameter and also some validation on parameters.
Is there some sort of guideline to what a person must do if a required field is not there or a validation failed.
Must you default values,throw exception, or use angularjs exception handling thing.
thanks
you are the one who has written a directive, you must be the one who should answer these questions...
guideline to what a person must do if a required field is not there or a validation failed.
only thing you can help with is making sure that if some required parameters are missing, is give some indication user of the directive, either by some exception logging or console messages etc.
its exactly like how angular tells us how to use ng-change or ng-click for that matter.

Resources