How do you Cache-bust individually rendered files while debugging? - system.web.optimization

Currently it is impossible for devs to easily work together. While debugging our code minification and bundling are turned off and so is the cache buster. This leads to every dev that touches javascript having to open every javascript file and force-refresh to make sure they aren't missing changes.
I found a couple references that I thought might work but none of the implementations have worked out yet.
The first is to apply a transform to the individual Bundles via an IBundleTransform.
Public Class DebugCacheBuster
Implements IBundleTransform
Public Sub Process(context As BundleContext, response As BundleResponse) Implements IBundleTransform.Process
If BundleTable.EnableOptimizations Then
Exit Sub
End If
For Each file As BundleFile In response.Files
file.IncludedVirtualPath &= GetPathHash(HostingEnvironment.MapPath(file.IncludedVirtualPath))
Next
End Sub
End Class
This looked promising but I have not been able to get it to work. I tried adding a new instance of this class to the constructor of each bundle and I also tried looping over all of the bundles after they were created. My break-points are hit and IncludedVirtualPath appears to have been updated. After continuing on with rendering the paths are not updated.
I also tried to create a custom VirtualPathProvider and a custom VirtualFile and overrode VirtualPath to return the correct value but again, when it rendered, the path was bare.
Did I do something wrong with the transform? Is there some other way to implement this?

Apparently this code will not work with version 1.1.0 of System.Web.Optimizations. After upgrading to version 1.1.3 (and adding an assembly binding redirect to solve a compatibility issue with Web Grease) the snippet in the question works flawlessly.

Related

Piranha CMS: Problem with custom block in manager interface

I am trying to add a custom block. I followed the steps in following two links:
http://piranhacms.org/docs/extensions/blocks
and
http://piranhacms.org/docs/manager-extensions/resources
In the CMS manager, I added the custom block to a page, but the block content is empty. Looks like the Vue.js didn't get associated to the custom block. I have set the block component attribute to the Vue.js.
I added the Vue.js by calling below method in the startup. Did I miss something to create a custom block?
App.Modules.Get<Piranha.Manager.Module>().Scripts.Add("~/assets/js/myscripts.js");
Move your "mycustomblock.js" file to the folder "wwwroot/js/" instead of the default "assets/js/". That way the file will be visible to Vue.js
Something is not working with the assets folder, probably it cannot be reached by Vue.js
after the Project is compiled. I had the same problem and this solution worked for me.
void Configure in Startup.cs will then look something like this (I simplified the syntax a bit compared to the documentation):
App.Modules.Manager().Scripts.Add("~/js/mycustomblock.js");
Adding a custom block and many other tasks have been difficult for me. Trial and error, and no knowledgebase to fall back on. The documentation is a fantastic start, and "Step by step" guides would be a good idea for the future (but I guess time is very limited).

Can't Programmatically Minimize Window

I'm trying to create a custom TitleBar for my game, i got everything else to work like i wanted but i can't get it to minimize without using the windows buttons from the windows frame.
I have a Game class with these in the constructor :
'Having this here or in the constructor doesn't make any difference
Public AsWindow As Windows.Forms.Form = CType(Windows.Forms.Form.FromHandle(Me.Window.Handle), Windows.Forms.Form)
Public Sub New()
Window.AllowUserResizing = False
Window.IsBorderless = True
end sub
Public Sub Minimize()
AsWindow.WindowState = System.Windows.Forms.FormWindowState.Minimized
End Sub
Calling Minimize cause a "System.NullReferenceException" on AsWindow, regardless of if i define AsWindow on runtime or during the initiation.
Note that i have added "System.Windows.Forms" as a reference.
Things i've tried:
This is where i got the initial code for the AsWindow field.
And here i tried to send a Message to minimize the window.
The problem you're facing is that the MonoGame API (which is exactly like XNA) doesn't expose a direct way of controlling the window. This kinda makes sense, because MonoGame supports platforms that don't have a concept of a "window" so to speak.
However, it's usually possible to get access to the underlying platform specific code and workaround these issues. It's important to keep in mind however that this approach will be platform specific and might break if MonoGame changes under the hood.
Last I checked, under the hood MonoGame uses SDL on the Windows desktop platform. This may not be true anymore, but I do have some code in an old project that gives the general idea. My code is in C# but it should point you in the right direction.
The first step is to import the method you want from the SDL.dll. This not managed code do you can't reference it like you normally would in .NET project.
[DllImport("SDL2.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void SDL_MaximizeWindow(IntPtr window);
Once you have access to the method you can call it by passing in the window handle.
SDL_MaximizeWindow(Window.Handle);
Obviously, this is code to maximize the window (that's the only code I had handy) but I'm sure you can figure out how to do the minimize version yourself.

Intellij unused Injects are not detected

I am trying to clean my code and delete #Inject fields in my classes which are not used. I tried to follow this https://blog.jetbrains.com/idea/2009/04/global-unused-declaration-inspection/ in order to achieve this. Somebody seems to have succeeded in making it work in the comments of the link but it didn't work at all for me. As soon as I add #Inject over my fields, there is no warning, even if the injected variable is private and never used !
Is this not supported for some reason or is there somewhere else I need to change the settings ? What I did was to set private on the inspection of the fields. I even tried to add an entry point on the Inject annotation. Needless to say that nothing of this worked.

"No appropriate method" error generated when calling new function using class-defined object

I defined a class called "FilterCriteria" which has a bunch of function .m files (getAMask, getBMask, etc.) associated with it. When I create the FilterCriteria object and call the functions using it, I don't have any problems. However, recently I added another function (which, on a side note, is almost identical to another function that still works), and Matlab returns the error, "No appropriate method, property, or field getHMask for class FilterCriteria."
I've searched online for this problem, but I can't find anything. The file getHMask.m is definitely in the correct folder, so I don't understand why Matlab seems to have such a problem finding it.
Here's getHMask.m's header:
function mask = getHMask(object, quadrant, channel)
Any help would be greatly appreciated. Thanks in advance.
1) A mistake I make sometimes is not saving the file with the correct name. Make sure capital letters are in the right places etc!
2) Another layer of error checking here... You can call methods('object here') (see here) and make sure it lists the method (function) that you are trying to add to it. If it doesn't show up here you should check into the implementation of the method and make sure it's correctly being added to the class you're using for your object.
I had the same problem that's kind of suggested by Ben's bullet #2 and it was driving me crazy. Turns out MatLab wasn't loading the latest version of my class's m-file. I vaguely remembered it gave me a warning earlier about that, because there were old instances of the class in the workspace and to keep from invalidating them it said it wouldn't update the class until I cleared the workspace...
So if that's the problem, restarting MatLab will work, or you can just enter >> clear

Why will some modules load and some modules not load in FLEX 3?

I have an app with several modules. There is only one module loaded at anyone time. 2 out of the 3 modules load without problems but the third a new module will not fire the ModuleEvent.Ready. I have an event handler function that handles the ModuleEvent.PROGRESS and it just traces out the bytes loaded vs bytes total. It seems to load the module completely yet never fires the ready event. Here is how I am loading the modules:
public var moduleInfo:IModuleInfo;
public function loadModule(url:String):void{
if(moduleInfo != null)
moduleInfo.release();
moduleInfo = ModuleManager.getModule(url+"?"+"x="+Math.random().toString());
moduleInfo.addEventListener(ModuleEvent.READY,moduleLoadHandler,false,0,true);
moduleInfo.addEventListener(ModuleEvent.PROGRESS,onModuleProgress,false,0,true);
moduleInfo.load(ApplicationDomain.currentDomain);
}
Ok, turns out it has been a long time since I created a new module. I forgot one critical thing. Since my modules are in separate projects, I need to change the root tag of the main mxml file from Application to Module. :)
Live and learn and never be ashamed to admit when you are wrong.