Flex Sub-Apps and MarhsallingSupport missing in 3.x SDK's - apache-flex

I'm looking at using Sub-Applications within flex, to enable mutli-versioned compilation.
Specifically, I'm looking to have a Flex 4.x host app that loads Flex 3.6 sub-apps.
The docs state this is possible (and the purpose of sub-apps). However they specify this:
When compiling each of these types of applications, you should include
the MarshallingSupport class into the main application and
sub-applications. You do this with the includes compiler argument, as
the following example shows:
-includes=mx.managers.systemClasses.MarshallingSupport
However, from what I can tell, MarhsallingSupport wasn't included until the 4.x releases.
Looking at the mx.managers.systemClasses package for 3.5.0.12683 and 3.4.1.10084 shows no reference of MarshallingSupport (see svn here and here)
This is also true for 3.6a (download of SDK available, but can't find the source).
Am I missing something? How am I supposed to include this class in the 3.x sub-apps, when it's not available?

see http://help.adobe.com/en_US/enterpriseplatform/10.0/AEPDeveloperGuide/WS8cbf8723eeed7311-4cca458e1328d74a115-7fff.html
Like module bundles, there are no special compilation requirements. You can build the
application bundle SWF in any way that is convenient. Note, however,
that application bundles must include marshalling support.
This is automatic with Flex 3, but with Flex 4 you must force the inclusion
of the MarshallingSupport class in your SWF.
For Flex 4 this can be
done by referencing the MarshallingSupport class in your application
code (as in the previous example). You can also explicitly force
inclusion of the MarshallingSupport class on the mxmlc command line
using the following option:
-includes+=mx.managers.systemClasses.MarshallingSupport

Related

Difference between Newtonsoft Json DynamicValueProvider and ReflectionValueProvider?

I'm in the process of porting a Asp.Net Core Website targeting the full framework to a website that targets Asp.Net Core 3.
In that process I have hit a snag. The website references the Newtonsoft 11.0.3 NuGet package and among other things uses the Newtonsoft.Json.Serialization.DynamicValueProvider class.
Interestingly that class exists when targeting the full framework but does not exist when targeting netcoreapp3.1 and so Visual Studio is producing compilation errors stating that the class doesn't exist. At first that seemed crazy to me, but I checked the source code for the class and sure enough it contains the following conditional compilation statement wrapped around the whole class
#if HAVE_REFLECTION_EMIT
Apparently the netStandard 2.0 dll in the NuGet package that my netcoreapp3.1 project would use causes the conditional compilation statement to not include the DynamicValueProvider class.
So I did some poking around in the Newtonsoft.Json.Serialization namespace and I see that there is a ReflectionValueProvider class available that does not contain such conditional compilation and is available when targeting netcoreapp3.1
I've looked at the source code for both the DynamicValueProvider class and the ReflectionValueProvider class and I'm unclear on the difference. Both appear to get or set the value of a property or member type based on the MemberInfo passed in into the constructor. Both appear to use reflection to accomplish their work. As I mentioned, apparently DynamicValueProvider needs reflection Emit ability and ReflectionValueProvider does not. Emit ability apparently is used to Emit IL as best I can tell.
So I wonder if perhaps the two are drop in replacements for each other except that maybe DynamicValueProvider might be faster since it apparently leverages IL Emitting. But that's just a hunch. I'd prefer to have a more concrete understanding of the differences between the two classes before I start swapping the one for the other in this existing codebase as a way to get to .Net Core 3.
Can you provide me with better insight into the differences between the DynamicValueProvider
class and the ReflectionValueProvider class, or at least confirm my hunch?
We had updated Newtonsoft.Json from 9.* to 12.0.3 version, and observed performance degradation on paths that includes json serialization. All paths lead to DynamicValueProvider. Fortunately, we had global descendant for DefaultContractResolver, and I was able to overload CreateMemberValueProvider method to return ReflectionValueProvider.
For now we are continue testing the new version, but I can say that from performance perspective ReflectionValueProvider works faster than DynamicValueProvider.
I think there is a correlation with the fact that NetStandard 2.0 is also used to build Xamarin.Forms applications for iOS which require an AOT compilation.
As written here:
Limitations of Xamarin.iOS
"Since applications using Xamarin.iOS are compiled to static code, it is not possible to use any facilities that require code generation at runtime."
and
"No Dynamic Code Generation.
The System.Reflection.Emit is not available"
For example, this is a System.Text.Json limitation that actually cannot be used in Xamarin.Forms projects for iOS. More info here.
System.Text.Json Serializer does not appear to work on Xamarin iOS

When referencing a .Net Standard project within a Xamarin solution, does all the code from the project get compiled into the app

Apologies if this sounds like a silly question. I'm not very experienced with how things are linked/bundled/assembled under the hood.
Before I begin, I'd like to say that I've tried reading documentation (such as https://learn.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/code-sharing) to find the answer, but was unable to.
If I have a Xamarin.Forms solution and I reference a .Net Standard project:
Question 1: Does all the code from this project get compiled and included into the app such that it may be disassembled later, or is it only code from classes that I actually make use of that gets included?
Bit more elaboration:
For example, I may have a School class that expects an IStudent (inject via DI), and a Student class that implements IStudent. Both of these exist in the .Net Standard project that I reference in the Xamarin.Forms project. However, if I only actually make use of the Student class (by registering it with type IStudent in my IoC container), will the code from School get included in the built app as well?
Question 2: If all the code from the project does get included, is there a way to forcefully specify which classes to include/exclude by way of some configuration setting, attributes, 3rd-party library, or something else?
As far as i know everything in the NETStandard project get compiled and shipped with the app.
If you want to remove unused code from compiled assemblies you have to use the linker.
To link everything, you have to select "Sdk and User Assemblies".
The linker tries to dont strip away mthods and fields you are using, but often is too aggressive (for example, methods referenced only by reflection will be stripped).
Luckily there are few methods where you can fine-tune the linker behaviour and make it work. Some link to elaborate on:
Linker in iOS and Android
https://learn.microsoft.com/en-us/xamarin/ios/deploy-test/linker
https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker
Official doc about the linker config:
https://learn.microsoft.com/en-us/xamarin/cross-platform/deploy-test/linker
Useful blogposts:
https://xamarinhelp.com/xamarin-linker/
https://medium.com/#harrycblum/reduce-your-xamarin-app-size-with-linking-26247edc87f6

How do I use functionality available in an embedded jar file?

I'm trying to use GmailSender in my Xamarin Android app. My main project is referencing the binding library, and the binding library has 2 jars - GmailSender 1.1.jar, and mail.jar.
the GmailSender 1.1.jar file is set as an EmbeddedJar in properties, and mail.jar is set as an EmbeddedReferenceJar in properties.
The following image depicts how my project is set up (higher res image: http://i.imgur.com/Xbq5uKa.png)
This is where I got GmailSender 1.1.jar: http://gmailsender.blogspot.ie/
This is where I got mail.jar (renamed from mail-6.0.0.jar) http://www.java2s.com/Code/Jar/m/Downloadmail600jar.htm
How can I get my Xamarin Android app to use GmailSender?
There is a note regarding that issue on Xamarin docs:
Note: Due to bug 6695, when referencing the Java Binding project
directly from a Xamarin.Android project, none of the namespaces,
classes, or other members of the Java Binding project will be visible
in the IDE when working on the Xamarin.Android project. This bug will
be fixed in a future version of Xamarin.Android.
You won't be able to see the bindings unless you reference the generated dll (this is a workaround)
You need to reference the library using the namespace of your binding library. By default, it is probably using "BindingLibrary1" as the root namespace, so try adding a using directive for that namespace.

How to include resource bundles in ActionScript Modules using Flex 4.1?

In the simplest of Flex Projects, create an MXML Flex Module and then load it using the ModuleManager. No problem. Create an ActionScript class that extends Module and then configure your project to compile that into a Module. Load this new module instead. The project compiles, but crashes when running with the following error:
"Error: Could not find compiled resource bundle 'containers' for locale 'en_US'."
I believe the compiler is failing to compile the required class definitions into ActionScript only module, while it succeeds for the MXML module. I can see that my skeleton MXML module is slightly larger than my ActionScript module (66KB vs. 45KB).
How can I resolve this problem (if that is indeed the issue)?
A good approach in these sort of situations is to use -keep-generated-actionscript for two projects, one with the mxml approach, and one with the actionscript approach. You can then compare the code to see what might be missing from one project, but included in another.
Have you tried adding an explicit reference to [ResourceBundle("containers")] to your ActionScript project class? The mxmlc is different to the compc compiler in behaviour for many valid reasons.
I was having this same problem when compiling a library swc. I was able to fix it by adding the following section to the projects projectName-config.xml
<include-libraries append="true">
<library>${flexlib}/locale/{locale}/framework_rb.swc</library>
</include-libraries>
This forces the compiler to include the framework resource bundle for the specified locale.
for me the issue was finding out which project - in my case a library - and which class in this library caused this behavior (I needed to realize my last changes - no info from flashbuilder). Then applying the following attribute to the class:
[ResourceBundle("containers")]
public class IpChecker {
...
That did the trick.

Warning when migratring from Flex 3 to Flex 4

I received this warning when I migrated my application from flex 3 to flex 4:
components:MyApp is a module or application that is directly referenced. This will cause components:MyApp and all of its dependencies to be linked in with modules:searchModule. Using an interface is the recommended practice to avoid this. Unknown Flex Problem
MyApp is a class which extends the Application component and in the module named "searchModule" there's this line:
var parentApp:myApp = parentApplication as MyApp;
I then use the variable myApp to call methods defined in the MyApp class from within this module.
This warning is reported 10 times because I am doing the same in other modules.
I want to fix it but I don't understand the part "this will cause its dependencies to be linked in with modules" and how would I make an interface to avoid this? And why there wasn't a warning about it in flex 3?
Thanks in advance
I'm guessing a bit, but...
The Flex Framework is one of those special Adobe-only libraries that can be cached by the Flex player. As such, with certain compile settings, the SWF from the compiler does not contain the Flex library. In lex 4, the framework is not compiled into your application SWf, resulting in significantly smaller application file size.
If you extend the Application class, which it sounds like you done, the compiler cannot count on your new "Application" being in the cached Flex Framework and therefore must compile your new class, and therefore the Application tag into your SWF. This is going to daisy chain significantly; as the Application tag does a lot of Flex Framework setup stuff.
I assume that is what the warning means in terms of dependencies.
Did you really extend Application with additional functionality? Or is "MyApp.mxml" just the name of the your main application file?
You might try this:
var parentApp:Application = parentApplication as Application;
I believe there is a FlexGlobals class introduced in Flex 4, which can also give you access to the top level Application.
In terms of using an interface. Interfaces are designed to help remove specific dependencies. You can create an interface for your new functionality of the new Application class and reference that instead.
var parentApp:myApp = parentApplication as IMyApp
Based on my interpertation of the messages you're seeing that may address the issue.
I had this error when I had Application MXML insted of Component MXML, for example.
Changed Application to Group, in referenced Component, and warning was no more.
Reason for error was, because I worked on component in separate project as application, and later copied it to main project, but I didn't change it to component.

Resources