I have recently migrated some of my projects to the shiny new Flex 4.6 SDK. I wasn't expecting much trouble since it was only a minor release. But as a matter of fact I got hundreds of errors all over the place. These errors would mostly come from Spark SkinnableComponents; for example:
override protected function getCurrentSkinState():String {
return mySkinPart.someProperty ? "normal" : "someOtherState";
}
would work just fine under 4.5, but would throw me a nullpointer error in 4.6. The reason is simple enough: in 4.6 getCurrentSkinState() is called before the skinparts are created, whereas in 4.5 I could be certain that the skinparts in the default state would be there.
Further investigation led me to believe that the initial state of a Skin is now undefined instead of the first state in the States array (until it calls getCurrentSkinState() that is).
Fixing these problems is usually pretty easy and requires just somewhat more defensive programming from my part. But that's not my real issue.
The real issue is that if the component lifecycle has changed, I'd like to know exactly what has changed and what parts of my projects might be affected.
I would be very appreciative if someone could shed some light on this or at least point me to the right place where I can read all about it (because the only release notes I could find were only covering the new mobile components).
Edit (this doesn't change the question; I just wanted to share my findings with you)
Another issue I just ran into: the dynamic modifier seems to no longer be inherited by subclasses. This is a pure ActionScript issue, so I guess it's the compiler that treats it differently.
Let me explain. Consider this class:
public class MyClass extends Array { }
Now, if I try to push a new item into this custom Array like this:
var t:Array = new MyClass();
t.push("hello");
SDK 4.5.1: no problem
SDK 4.6: "Cannot create property 0 on MyClass" at runtime
Apparently that's because Array is dynamic and MyClass isn't, so it's easily fixed:
public dynamic class MyClass extends Array { }
and the error's gone.
But what if I used a third-party library that has code like this and to which I had no source code access? My application would break and there's no way I could fix it. I mean: come on, that's no minor change for a dot-release.
I think there are two questions in there.
1 ) The real issue is that if the component lifecycle has changed, I'd
like to know exactly what has changed and what parts of my projects
might be affected.
I haven't seen a comprehensive low-level analysis of the differences between the two version. If you are really concerned, and you have the time to spare, you could use a diff tool to compare the source code for the two SDK's. There shouldn't be too many major structural changes - e.g. renamed classes or packages, so it might not be so bad. I expect a lot of classes won't have changed at all.
2 ) Another issue I just ran into: the dynamic modifier seems to no longer
be inherited by subclasses. This is a pure ActionScript issue, so I
guess it's the compiler that treats it differently.
This one is easier. dynamic has never been inherited. Object is dynamic, so if the attribute was inherited every class would have to be dynamic too.
If there appears to be a change in behaviour related to dynamic class instances, then there is something else going on in your code.
Related
An ASP.NET Core 2.1 MVC app, using Autofac following their documentation on setup (https://autofaccn.readthedocs.io/en/latest/integration/aspnetcore.html).
I am trying to resolve a dependency in a custom ValidationAttribute. The returned value from valicationContext.GetService is always returning null. Inspecting the validatationContext the private member serviceProvider is always null.
what am I missing in the setup that this isnt working. The dependancies resolve everywhere else in the app, just not in the ValidationAttributes.
public class MyCustomAttribute : ValidationAttribute
{
public MyCustomAttribute ()
{
}
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
// THIS IS ALWAYS RETURNING NULL
var IMyService service = (IMyService)validationContext.GetService(typeof(IMyService));
return ValidationResult.Success;
}
}
I can't say I've tried this before, but doing some searching I found this issue which seems to indicate that the service provider (not the ServiceContainer property, but the service provider that will respond to GetService calls) should always be populated. Granted, that's from an archived repo from early on in .NET Core, but it should still hold.
Looking at the source for ValidationContext I see that the private serviceProvider field is actually a function that needs to be instantiated somewhere; it's not actually a reference to a provider proper. That means if it's null, one of two things is happening:
The path through ASP.NET Core that's instantiating that ValidationContext is not passing in the IServiceProvider required to provide services.
Something is broken.
If it's #1, I'd guess there are a variety of potential reasons. I'd think about things like...
The attribute is being used by something running outside the "ASP.NET Pipeline" - like a manually invoked validation or possibly something at application startup where there's no request at the moment.
The attribute is being used in a test where the full pipeline isn't in effect.
Something like that. I'm not saying this is what's happening, but I've seen questions like this before where it appears something isn't working right when it's actually an application code problem. For example, there are lots of questions about why "instance-per-request" dependencies aren't working and it turns out the code is running on a background thread where there's no request so... yeah. I don't know how your app works, but that sort of "I'm doing something I forgot to mention because I didn't think it was relevant" stuff comes into play here.
Let's assume you've got a super vanilla ASP.NET Core app, though. Based on the issue I mentioned earlier and the code you've posted, this looks like it should work but it's not. There shouldn't be anything you need to wire up for this, it should just work. Given that, you might want to file an issue about it. You may have found something that legitimately isn't working.
Before you do that, you might want to debug a little more. You can step right into ASP.NET Core source code and that could help you figure out what's up. The article I linked there explains how to set it up. It's not a two step process and needs screen shots to help or I'd put it right in here.
Set a breakpoint on your failing statement up there and then switch over to the Visual Studio "call stack" window. Click on the call stack frames higher up in the stack and see what's actually creating that context object. With a little clicking around and intuition you can probably figure out where the issue is. Maybe it'll point to something in your app you didn't realize you were doing, maybe it'll point to a bug in ASP.NET Core. If it's a bug in ASP.NET Core, having the information you found from your debugging session will be really helpful to that team.
Finally, I'd be remiss if I didn't mention that manually resolving a service in an attribute like this is technically service location rather than dependency injection and it'd be a better all-around solution if you avoided it entirely. There's an extremely similar question to yours right here walking through how to get around this with Simple Injector, though the principle holds for Autofac, too. Setting up model validators and using a model validator provider rather than attributes might be a better, more testable way to go. The answer in that question has more explanation on this.
I am trying to make changes to the behavior of a function and print the results to a file. The ViewCfg plug-in described in the Plug-in Development Guide does something similar, but I am trying to avoid having to use Ast.get, which ViewCfg uses. I am thinking of extending Printer.extensible_printer which, according to the Frama-C API Documentation, is something I can do if I want to obtain a custom pretty-printer.
However, if I extend the pretty-printer as described in the API docs, unless I'm doing something wrong, I notice that the changes I make take place regardless of which project is set as the current project. I'm using File.create_project_from_visitor to create a new project and Project.set_current to set the new project as the current project before I use the custom pretty-printer.
Is it true that any change made by a class that extends Printer.extensible_printer applies to all projects? I happen to be using frama-c-Aluminium-20160502, which I know is not the latest version.
EDIT: Sorry, I should have made this clearer in the beginning, but I'm not actually making changes to the behavior of a function. I'm reading in the behavior of a function, then based on that, I'm trying to generate as output valid C code that's meant to be read as input by another program.
Regarding AST.get, the only reason I was avoiding it was that it sounds like it gets the entire AST, while I'm only interested in part of it, i.e. behaviors. But if I'm just making things harder for myself by avoiding it, then I'll go ahead and use it.
VS2015 shows how many references there are to a class.
However if the class is started by WebApplication.Run the references are not shown.
The highlighted code does get executed when the application is run.
Is there any way to get the reference count for the Configure method?
Here are two reasons ;)
The Startup Class is invoked by reflection (it does not implement an interface)
I doubt that code pieces outside of your local source code will influence the reference count. So even if somewhere deep in WebApplication.Run the Configure method is invoked (assuming directly over some magic interface), the reference code will not rise. Make sense, otherwise the counter for string would have overflow ;)
Over the past three weeks, I have lost at least 120 man hours because of some lesser known functionality in ActionScript 3. One of the problems was that, with Internet Explorer, if there are too many messages sent through LocalConnections, it will slow the messages sent through, but in the standalone player and in Firefox, this threshold is significantly higher. Another was that the static values of a class are instantiated even if the member itself is not being used:
import path.to.FooClass;
private function thisIsNeverCalledButItEnsuresThatFooClassIsImported():void
{
var f:FooClass = new FooClass();
}
Since FooClass had a static reference to a Singleton, that Singleton was instantiated so when I loaded a Module which used that Singleton, it would bind to values in an unpredictable way.
Additional cases where things behave in an unexpected way:
MovieClip.addFrameScript
flash.trace.Trace as a class
int is a faster incrementer class, Number is faster for mathematics, and uint is incredibly slow.
PrintDataGrid, if it has only one page, needs to have an empty value appended to the end of its dataProvider
If you use try...catch around two LocalConnections and connect them to the same channel, you will force garbage collection without needing System.gc
So here's the question (and I'm sorry for omitting this in the original post), is there any consolidated documentation for this type of behavior anywhere? Is there any (even non-Adobe) documentation on these issues (websites, forums, books, ANYTHING)? I know that these things are definitely easy enough TO document, but has anyone done so?
If not, am I missing anything? Are there other issues which I should know about?
This kind of useful information is very often not "centralized". Moreover, what you are looking for is something related to the experience of the programmer (more than to official docs).
FYI, there are two other methods for ensuring a class is included.
#1 - This syntax is actually used in the Flex source code:
import path.to.FooClass; FooClass; // note double reference
public class References
{
// No references needed in this class
}
#2 - Use the includes command line argument
-includes path.to.FooClass
You can always submit your experience using the "feedback" section in the help. Unfortunately, this is less obvious than the link that used to be at the bottom of each page in the older help files (which also served the useful function of opening a browser window with the web version of that help page).
Adobe says that it incorporates the comments from previous versions of the help into new versions, but my own observation suggests that there are instances where it does not happen. However, that and the appropriate cookbook are still the best avenue for those who believe that this kind of information should be centralized.
Note that the whole purpose behind modules is to avoid compiling code multiple times, so importing FooClass kind of defeated the purpose. The problems you had in this instance are just one of the many that happen if you use Singletons, and it's unfortunate that the first official Framework, Cairngorm, encouraged their widespread use. Check out http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/ .
I am new to ActionScript 3 and have run into a problem:
Using Flex Builder 3, I have a created a project with a few simple classes. If code in class A instantiates an object of class B (class B is in its own source file) then the code compiles fine, but I get the following run time error:
ArgumentError: Error #2012: B class cannot be instantiated.
Can someone explain what I'm doing wrong?
Update: Please see my own answer below (I could not vote it to the top since I'm not yet registered).
I finally realized what was wrong: Class B was subclassing from DisplayObject which I now see is an abstract class. Class B did not implement the abstract members, thus the error. I'll probably change class B to subclass from Sprite instead.
This seems like a problem that should have been caught by the compiler. Does the fact that it wasn't mean implementation of abstract members can wait until run time? Even if so, it would be nice to at least get a compiler warning.
Thanks for everyone's answers, hopefully they will help others who run into error 2012.
This usually means that the class information was not included in the SWF.
Make sure that you are importing the class, and that there is a reference to it somewhere (so the compiler will included it in the SWF).
btw, here are the runtime error codes:
http://livedocs.adobe.com/flex/201/langref/runtimeErrors.html
(not much useful info though)
mike chambers
mesh#adobe.com
It's worth noting that if you're including classes that someone else built, and they used Flash CS3 and you're using Flex, or vice versa, that the core libraries of each are different and some things are not included in both. Check out the two reference docs to be sure:
CS3: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
Flex: http://livedocs.adobe.com/flex/2/langref/