Collecting Visual Studio Intellisense results from command line - json

When you open json files that have a "$schema" property in Visual Studio 2017, intellisense will add messages to the Error List window describing which lines in the file do not match the schema (e.g. missing required property, wrong data type, doesn't match pattern, etc.). This only happens if the file is currently open.
I would like these results to show up when I build (even if the json files are not open). I don't want to make an extension to do it, but I do currently run a custom executable during the build. I know how to format the output of the executable so that errors and warnings generated by that tool show up in the Error List window.
Basically, I am wondering if I can use that to somehow force the intellisense results specifically from the json files to appear in the Error List window. I would like to have the ability to promote some of the messages to errors and some to warnings, so I don't just want to hack it in by forcing the json files to open during the build. (Can I somehow use MsBuild to get intellisense results from json files?)
If there is no way to collect the results of intellisense in an external tool, then I will most likely use a completely separate json validation library instead. I just wanted to save the effort since it is built into Visual Studio. Thanks.

It turns out that NJsonSchema (https://github.com/RSuter/NJsonSchema) is so easy to use. If anyone has ideas about intellisense, that may still be useful, though.

Related

Cypress mocha-junit-reporter - pass test filename to reporter output filename

I'm using Cypress to run a suite of automated tests.
The current version of cypress provides mocha-junit-reporter out of the box, and provides configuration options to pass to the reporter. One of the options is the 'mochaFile'.
I'm using the recommended [hash] tag to output reports across multiple spec files.
this results in a flat mess of files that look like 'results/test-output-abc12345.xml'.
What I want instead is for the test file's relative path and filename to be pass in as the reporter's output file path.
This would give me a structured, feature first view of the output, and in Azure Dev Ops, which aggregates the test output, it would give me correct filenames to detect intermittently failing tests.
Things I've tried that haven't worked:
I've tried to use hooks to modify Cypress's config or set environment variables to try to override the reporterOptions/mochaFile per test at (hopefully) the right time.
I've tried to grab the outputted defaultly-named xml file, and copy it to the correct path+filename given the Cypress.spec.name context, but I can't seem to find the right hook or time to do this.
after and afterEach don't work - I don't think the test report has saved the file yet.
Using a plugin, hooking to some event on test:before:run or test:after:run seem promising, but I'm flying blind since I can't debug into it, so I've been unsucessful in modifying the reporter's output path or copying the file.
I'd love it if someone could show a working example using mocha-junit-reporter, or even a different mocha compatible reporter, if the reporter would play well with Azure Dev Ops, and can help me discover intermittently failing tests.

PhpStorm: how to apply external tool (jpegoptim) on many files?

I am using jpegoptim in PhpStorm as external tool.
Works fine when I do select 1 file.
How can I apply that on many JPEG files ?
That's not possible at the moment (not supported).
https://youtrack.jetbrains.com/issue/IDEA-90239
https://youtrack.jetbrains.com/issue/IDEA-97869
Watch these tickets (star/vote/comment) to get notified on any progress.
If you definitely need it in one go (and not calling that External Tools entry once for each file)... then what you may try is:
Select desired files
Use Copy Paths from context menu
Call another External Tools entry that:
Uses $ClipboardContent$ macro
It's some shell/batch script that parses such parameter (splits into separate lines to get individual paths) and then calls actual program in cycle -- once for each file from the parsed parameter.
A bit too complicated as for my liking... Plus, I've not tried it myself so not sure how line ending symbols will be passed here (so it can be parsed in the script).
BTW -- you can assign custom shortcut to particular External Tools entry so you may call it for each file individually -- it will be faster with shortcut than doing the same with the mouse.

How to format pasted JSON in IntelliJ / Android Studio

I often need to use a text editor while writing code to paste random notes but especially JSON responses, where I format them using a plugin (for Sublime).
I recently heard about the 'scratch file' feature in IntelliJ / Android Studio which does exactly what I need it to - except I can't make it format JSON I paste in nicely.
How can I make Android Studio format JSON in a scratch buffer file?
I highlight the code and run Command Option L (a short-cut for the Code->Reformat Code menu).
On Windows use Ctrl Alt L.
Note that this only works if the code is well-formed JSON (clear any red squiggles).
You are asking about two seperate things: scratch files and scratch buffers.
When you create a scratch file in IntelliJ you can choose the type of the file (e.g. JSON) that you want to create. Based on file's type, IntelliJ provides code formatting (use Code->Reformat code).
However, scratch buffers are just simple .txt files and the only formatting that can be used is the one associated to .txt format. So, if you put JSON into scratch buffer it won't get formatted with JSON type formatter.
I would encourage you to use scratch files instead of scratch buffers if you want JSON formatting.
More information can be found at IntelliJ's official page https://www.jetbrains.com/help/idea/2016.2/scratches.html.
choose from the menu : code -> reformat code
hotkey On Windows -:
CTRL + Alt + L
Important note- if you have sensitive information in your JSON- NEVER use online tools to parse or beautify it. because this will compromise your organization's and customer's information
If you run the latest version I'd create a new Scratch File of type JSON.
It's really easy, e.g. hit double shift, then search for new scratch file, select JSON as the language, paste your snippet and then use the shortcut that you usually use for formatting any file in intelliJ.
There is a plugin Save Actions that does auto-formatting (also of JSON) every time when I save the file:
select Android Studio > Preferences > Plugins
check Martketplace tab and search for Save Actions (it has a red square-ish icon) and press Install next to it.
At this point you will need to restart your android studio, and then you can enable "Reformat on save" by:
select Android Studio > Preferences > Other Settings > Save actions, in there, select:
✅ General > activate save actions on save
✅ Formatting actions > Reformat File

How to display Visual Studio loadtest result file (.trx) into readable format?

I would like to execute my load tests on the regular basis and make it part of my CI process.
I'd like to run a Visual Studio loadtest from the console and provide the results of the test in human readable format (preferably HTML page).
For executing the test I use MSTest.exe util which produces .trx file to specified location.
e.g.
mstest /TestContainer:LoadTest.loadtest /resultsfile:c:\Temp\MyResults.trx
My problem is to convert this .trx file into something which can be displayed in browser.
I tried several tools mentioned in another topics like trx2html converters and so on. All of them were built for conversion of unit tests and fail to convert load test results correctly.
Any suggestion please?
An alternative would be to use the "archive artifacts" option in Jenkins for the **/*.trx file(s). That way you can click on the link and the trx file will open in Visual Studio.
Of course that means this is only of use to people with Visual Studio installed.

How can I get Visual Studio 2013 to use a custom JSON schema?

I am working on a project that involves the use of JSON to store and retrieve data; in order to write some example data I am using VS2013's JSON editor, which supports, supposedly, the use of arbitrary JSON schema for its Intellisense code-completion feature. However, I have not been able to get it to recognise any schemata that are not accessed through a website, e.g. http://json-schema.org/draft-04/schema works fine but /JSON/mySchema.json does not.
It will not load /JSON/mySchema.json from the $schema tag, nor will it allow me to type in its name; whenever I type it into the schema box and hit enter, it returns the schema box to "No Schema Selected".
How do I get VS2013 to recognise my custom schema and generate Intellisense completion from it?
I've learned (from comments on the announcement page for this functionality) that using relative paths for JSON schema is currently bugged in Visual Studio 2013 Update 3;
"[...] the relative $schema path is not working in a non-web project and will be fixed in Update 4."
(from a comment on this page)
It should work fine with an absolute path, but of course that's not portable. Update 4 should be out soon; the RC is already out, and information can be found here.