Visual Studio 2013; just my code - mycode.json - debugging

I'm trying to figure out the mycode.json file that can be used in combination with the "just my code" service of Visual Studio 2013. However it's not making sense to me
For those who know not what "just my code" is:
http://blogs.msdn.com/b/visualstudioalm/archive/2013/11/25/just-my-code-for-asp-net-in-visual-studio-2013.aspx
This is my scenario
I have a project that is using jquery libraries and my own custom js file, called myconsents.js
I want to be able to debug this only, but for some reason the debugger keeps jumping into the jquery libraries.
This is how my mycode.json file looks like
{
"Eval" : "MyCode",
"Function" : "Library",
"ScriptBlock" : "Unrelated",
"MyCode" : [
"myconsents.js"
],
"Libraries" : [
"*.min.js", "jquery.*.js", "jquery-*.js"
],
"Unrelated" : [
]
}
I hope you can provide a solution
Thanks

I found that Visual Studio was ignoring my mycode.json file because I had put a JavaScript-style comment at the beginning:
// http://msdn.microsoft.com/en-us/library/dn457346.aspx#BKMK_JavaScript_Just_My_Code
{
"MyCode": [ ],
"Libraries": [ "*-min.js" ],
"Unrelated": [ ]
}
VS started working as expected after removing the comment.

Related

ExcelJS - Strict-mode does not allow assignment to undefined variables: regeneratorRuntime

I'm using DevExtreme dxDataGrid and I want to export data to an xlsx-file. They have implemented it using ExcelJs:
https://js.devexpress.com/Documentation/ApiReference/Common/Utils/excelExporter/#exportDataGridoptions
As explained I just need to reference the following libs:
<head>
<!-- ... -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.4.0/polyfill.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.1.1/exceljs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.2/FileSaver.min.js"></script>
<!-- reference the DevExtreme sources here -->
</head>
I'm using ASP.NET Core 6 with VS 2022. For this I'm using the Bundler & Minifier to bundle libs like jQuery, DevExtreme and ExcelJs.
I have downloaded ExcelJs (like I have done for jQuery etc.) with libman.json:
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": [
{
"library": "jquery#3.6.0",
"destination": "wwwroot/js/lib/jquery/"
},
{
"provider": "cdnjs",
"library": "exceljs#4.3.0",
"destination": "wwwroot/js/lib/exceljs/",
"files": [
"exceljs.min.js",
"exceljs.js"
]
},
{
"provider": "cdnjs",
"library": "FileSaver.js#2.0.5",
"destination": "wwwroot/js/lib/FileSaver.js/"
},
{
"provider": "cdnjs",
"library": "babel-polyfill#6.26.0",
"destination": "wwwroot/js/lib/babel-polyfill/"
}
]
}
Then I have added ExcelJs to my bundleconfig.json:
[
{
"outputFileName": "wwwroot/bundle/LibraryBundle.js",
"inputFiles": [
"wwwroot/js/lib/jquery/jquery.js",
"wwwroot/js/lib/babel-polyfill/polyfill.js",
"wwwroot/js/lib/exceljs/exceljs.js",
"wwwroot/js/lib/FileSaver.js/FileSaver.js"
]
}
]
Then I'm getting following error in Visual Studio:
Strict-mode does not allow assignment to undefined variables: regeneratorRuntime
strict-mode is defined in ExcelJS and also many other lib's I don't understand why I'm getting this error and how can I fix it. I was not able to find any similar issue at Github-ExcelJs and it doesn't look like that they are not really supporting their open issues. Because of that I'm tried to ask here.
I am still on ExcelJS 4.2.1, but I was running into a similar issue.
Based on this comment on an ExcelJS issue, in the exceljs.js file, this is the offending block of code:
try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
// This module should not be running in strict mode, so the above
// assignment should always work unless something is misconfigured. Just
// in case runtime.js accidentally runs in strict mode, we can escape
// strict mode using a global Function call. This could conceivably fail
// if a Content Security Policy forbids using Function, but in that case
// the proper solution is to fix the accidental strict mode problem. If
// you've misconfigured your bundler to force strict mode and applied a
// CSP to forbid Function, and you're not willing to fix either of those
// problems, please detail your unique predicament in a GitHub issue.
Function("r", "regeneratorRuntime = r")(runtime);
}
NEW workaround from Phoniex is to create a file with simply
var regeneratorRuntime;
in it, and include it before the exceljs.js file.
OLD workaround is to replace the assignment in the try block with:
window.regeneratorRuntime = runtime;

WebStatus wont compile: The "jquery#3.4.1" library could not be resolved by the "cdnjs" provider

I have the eShopOnContainers solution here: https://github.com/dotnet-architecture/eShopOnContainers. I have been actively working on a variation of it for the last few years. I attempted to compile it this morning and the WebStatus project causes this error:
libman.json(0,0): Error LIB002: The "jquery#3.4.1" library could not be resolved by the "cdnjs" provider
I have found this: https://github.com/aspnet/LibraryManager/issues/685 and this: https://issuemode.com/issues/cdnjs/cdnjs/94570425 (updated yesterday)
So far I have tried what is suggested in the articles:
dotnet tool install -g Microsoft.Web.LibraryManager.Cli (installs version 2.1.75)
libman cache clean
libman restore
Is there anything else I can try? My Libman.json looks like this:
{
"version": "1.0",
"defaultProvider": "cdnjs",
"libraries": [
{
"library": "jquery#3.4.1",
"destination": "wwwroot/lib/jquery/"
},
{
"provider": "unpkg",
"library": "bootstrap#4.1.3",
"files": [
"dist/css/bootstrap.css",
"dist/css/bootstrap.css.map",
"dist/css/bootstrap.min.css",
"dist/css/bootstrap.min.css.map",
"dist/js/bootstrap.js",
"dist/js/bootstrap.min.js"
],
"destination": "wwwroot/lib/bootstrap/"
}
]
}
Try this:
-Right click libman.json
Disable Client-Side libraries on build
Build the project

electron-builder: How can I remove deeplinking protocols once the program is uninstalled?

I am working on a project using electron and electron-builder. I have implemented deeplinking protocols in my package.json file. after removing the app on windows the deeplinking protocol still persists. I need this to not persist.
i have tried:
1) deleting my %appdata%\program folder as-well
2) restarting my pc after uninstallation.
3) clearing my browser's cache.
{
"name": "program",
//...
"scripts": {
//...
},
"build": {
//...
"protocols": {
"name": "electron-deep-linking",
"schemes": [
"deeplinkingURI"
]
},
"win": {
"artifactName": "program.${ext}",
"target": [
{
"arch": [
"ia32",
"x64"
],
"target": "nsis-web"
}
]
},
//...
},
//...
}
after uninstalling my program, the deeplinking still works (it does not launch the app because it obviously has been uninstalled, but a prompt still appears attempting to launch nothing).
I suspect that something remains within my windows registry.
NOTE: this problem does not occur on macOS
So I've figured out the answer to my own question (not me but colleagues). there is a registry file under computer\HKEY_CLASSES_ROOT\deeplinkingurl that must be deleted at uninstall via script.
there is another question (that i did not see before, forgive me) that gives more details.

Performance Issues - Chutzpah Console.exe and TypeScript

I am running into some performance issues trying to run the chutzpah.console.exe with my chutzpah.json file. For this project, I am using TypeScript and pre-compiling the TypeScript files into .js files before running the tests. Each test file that I have generally references one other TypeScript file that it depends on - this is so Visual Studio is happy and so that the Chutzpah extensions work. For example, my drawerBusiness.spec.ts file contains this reference:
/// <reference path="../../../../app/business/documents/drawerBusiness.ts"/>
My chutzpah.json file is as follows:
{
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ]
},
"Framework": "jasmine",
"TestHarnessReferenceMode": "Normal",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"References": [
{ "Path": "./lib/jquery/jquery.js" },
{ "Path": "./lib/angular/angular.js" },
{ "Path": "./lib/angular-mocks/angular-mocks.js" },
{ "Path": "./lib/jasmine-jquery/jasmine-jquery.js" },
{ "Path": "./lib/underscore/underscore.js" },
{ "Path": "./lib/angular-bootstrap/ui-bootstrap-tpls.js" },
{ "Path": "./tests/dependencies.js" }
],
"Tests": [
{ "Include": "*/tests/specs/*.ts", "ExpandReferenceComments": "true" }
]
}
As you can see from above, I need to load some external libraries. I presume these get loaded once and then are used for each of the tests?
When I was using pure JavaScript, this configuration was blazing fast. It completed quite quickly in Visual Studio and through running the tests from the chutzpah.console.exe. However, since I have switched over to Chutzpah, the tests are much slower:
Tests complete: 263
=== 263 total, 0 failed, took 74.64 seconds ===
These results are even worse on our build machine, and it's timing out. It seems like there's a huge delay between each spec file that is run, and I think that is causing the overall slowness - once the spec file starts running, it completes in a few one-hundredths of a second. Does anyone have any ideas about what could possibly be configured incorrectly?
Here are a few things you can try to help get to the bottom of this issue:
Can you try enableding "EnableTestFileBatching": true in your chutzpah.json file to see if it helps? There can be slowness if you have MANY test files and this setting tells chutzpah to batching them into one harness.
Can you provide the output of the /trace option so I can see all the timings?
Can you provide a repro that I can run locally?

ReferenceError in Jasmine test using Chutzpah and ReSharper

I'm using Jasmine and Chutzpah to test my TypeScript project in Visual Studio 2013 with PhantomJS. If I run the tests using the Chutzpah context menu extension they work fine but when I run them using the ReSharper test explorer, they fail if there are any external dependencies. The error message is ReferenceError: $ is not defined.
My project structure looks like:
- Scripts
- MyApp
- Components
- DatePicker.ts
- Tests
- Components
- DatePickerTest.ts
- typings
- jquery
- jquery.d.ts
- jquery-1.10.2.js
Chutzpah.json
Chutzpah.json looks like
{
"Framework": "jasmine",
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ]
},
"References": [
{
"Includes": [
"*/Scripts/jquery-1.10.2.js"
],
"Excludes": [ "*/Scripts/*.d.ts" ]
}
],
"Tests": [
{
"Includes": [ "*/Scripts/Tests/*.ts" ],
"Excludes": [ "*/scripts/Tests/*.d.ts" ]
}
]
}
DatePickerTest.ts looks like
/// <reference path="../../myapp/components/datepicker.ts" />
import DatePicker = MyApp.Components.DatePicker;
describe("Datepicker", () => {
var datePicker: DatePicker
beforeEach(() => {
datePicker = new DatePicker();
});
// tests
});
Instantiating the DatePicker fails with the message ReferenceError: $ is not defined because the class uses $.extend() in the constructor.
I've tried declaring the reference to jQuery at the top of the test by adding the line /// <chutzpah_reference path="../../jaquery-1.10.2.js" /> but that doesn't make any difference. Plus my understanding is that adding references in the Chutzpah.json means I shouldn't have to do this anyway.
As suggested in this answer, I have debugged my test in the browser and sure enough jQuery isn't being loaded in the index.html page, so what am I doing wrong?
The problem came down to how ReSharper attempts to resolve dependencies based on the type definition references it finds. The ReSharper unit testing docs say:
If your test file references and (sic) external JavaScript library using a declaration file (*.d.ts), ReSharper will search the original JavaScript file by the name of the *.d.ts file.
My class under test was referencing the jQuery definition file:
/// <reference path="../../typings/jquery/jquery.d.ts" />
The problem was that I also have jquery.cookie.js included in my project (as part of Foundation), and ReSharper was incorrectly including that instead of jquery-1.10.2.js.
Renaming or removing jquery.cookie.js allowed ReSharper to find the correct jQuery file and solved the problem.

Resources