I've run into a weird problem with Visual Studio 2017 (Enterprise, version 15.5.2) that I can only replicate on one specific machine. The problem doesn't occur on other development machines.
Given a file foo.resources.json with the following contents:
{
"FooReparatur": "Reparatur",
"FooVerlust": "Verlust",
"FooWema": "Wema"
}
Applying the quick action Sort Properties results in the keys being in the wrong order:
{
"FooReparatur": "Reparatur",
"FooWema": "Wema",
"FooVerlust": "Verlust"
}
The configured language for Visual Studio is English, there is no schema selected for the given file. The configured language for Windows is Estonian, but the sorting order is wrong by that alphabet as well.
I checked for any funny unicode characters or anything similar via a hexdump, but found nothing of the like either. As mentioned before, the file sorts correctly on all other machines.
I've tried disabling all the (default) extensions the installation has, but that doesn't resolve the problem either.
I've looked through most of the settings for both general text editing and the specific file type, but I can't find a setting that could cause this. What could be the issue? How can I debug this further?
This is a property of Estonian collation where 'V' and 'W' are treated as the same character. Hence, the next character that differs will be the significant one. As can be demonstrated by this C# code using .Net.
var words1 = new[] { "FooR", "FooVer", "FooWem" };
var words2 = new[] { "FooR", "FooVa", "FooWb" };
var estonianCultureInfo = new System.Globalization.CultureInfo("et-EE");
var estonianComparer = StringComparer.Create(estonianCultureInfo, false);
var sortedWords = words1.OrderBy(x => x, estonianComparer);
foreach (var word in sortedWords)
{
Console.WriteLine(word);
}
Console.WriteLine("[-----]");
sortedWords = words2.OrderBy(x => x, estonianComparer);
foreach (var word in sortedWords)
{
Console.WriteLine(word);
}
Output:
FooR
FooWem
FooVer
[-----]
FooR
FooVa
FooWb
Try to use this plugin to sort :
https://marketplace.visualstudio.com/items?itemName=richie5um2.vscode-sort-json
If dosn't work, try to install again the visual studio and choose language English to test if it work
Good Chance.
Related
I used to be able to put a break point in a javascript function and change variable values to debug. This worked until recently (within a week or two).
Here's an example:
function test(params) {
var result = params.num * 2;
// if I put a break point here and change result = undefined,
// it doesn't work
return result;
}
// I should get 6, but when debugging and changing result to undefined,
// I should get undefined in my output, used to, not anymore
var x = test({ num: 3 });
console.log(x);
I'm using OSX Yosemite Chrome v. 49.0.2623.110 (64-bit)
It is up to date and I just restarted Chrome.
I do this all the time, but something happened recently and I can't anymore. Any help would be greatly appreciated.
Thanks
It looks like this was documented behavior for a while. Just yesterday a change was made to the code that says it will restore the ability to change variables. It is very disappointing that they allowed it to break for any length of time.
https://bugs.chromium.org/p/chromium/issues/detail?id=569811&q=debugger%20change%20variable&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified
The Reference Source page for stringbuilder.cs has this comment in the ToString method:
if (chunk.m_ChunkLength > 0)
{
// Copy these into local variables so that they
// are stable even in the presence of ----s (hackers might do this)
char[] sourceArray = chunk.m_ChunkChars;
int chunkOffset = chunk.m_ChunkOffset;
int chunkLength = chunk.m_ChunkLength;
What does this mean? Is ----s something a malicious user might insert into a string to be formatted?
The source code for the published Reference Source is pushed through a filter that removes objectionable content from the source. Verboten words are one, Microsoft programmers use profanity in their comments. So are the names of devs, Microsoft wants to hide their identity. Such a word or name is substituted by dashes.
In this case you can tell what used to be there from the CoreCLR, the open-sourced version of the .NET Framework. It is a verboten word:
// Copy these into local variables so that they are stable even in the presence of race conditions
Which was hand-edited from the original that you looked at before being submitted to Github, Microsoft also doesn't want to accuse their customers of being hackers, it originally said races, thus turning into ----s :)
In the CoreCLR repository you have a fuller quote:
Copy these into local variables so that they are stable even in the presence of race conditions
Github
Basically: it's a threading consideration.
In addition to the great answer by #Jeroen, this is more than just a threading consideration. It's to prevent someone from intentionally creating a race condition and causing a buffer overflow in that manner. Later in the code, the length of that local variable is checked. If the code were to check the length of the accessible variable instead, it could have changed on a different thread between the time length was checked and wstrcpy was called:
// Check that we will not overrun our boundaries.
if ((uint)(chunkLength + chunkOffset) <= ret.Length && (uint)chunkLength <= (uint)sourceArray.Length)
{
///
/// imagine that another thread has changed the chunk.m_ChunkChars array here!
/// we're now in big trouble, our attempt to prevent a buffer overflow has been thawrted!
/// oh wait, we're ok, because we're using a local variable that the other thread can't access anyway.
fixed (char* sourcePtr = sourceArray)
string.wstrcpy(destinationPtr + chunkOffset, sourcePtr, chunkLength);
}
else
{
throw new ArgumentOutOfRangeException("chunkLength", Environment.GetResourceString("ArgumentOutOfRange_Index"));
}
}
chunk = chunk.m_ChunkPrevious;
} while (chunk != null);
Really interesting question though.
Don't think that this is the case - the code in question copies to local variables to prevent bad things happening if the string builder instance is mutated on another thread.
I think the ---- may relate to a four letter swear word...
I'm using someone else's code (licensed) on two different machines. On one machine, the Application.ExecutablePath returns the result the programmer must have expected, on the other it does not. Both are Windows 7 machines.
On my machine, the Application.ExecutablePath returns something like:
"C:\\Dir1\\Dir2\\Dir3/bin/Debug/APP.EXE"
On the other machine, it returns
"C:\\Dir1\\Dir2\\Dir3\\bin/Debug/APP.EXE"
The programmer obviously expected the second return string, because the code does this:
string path = Application.ExecutablePath;
short found = (short)path.LastIndexOf(#"\");
if (found > -1)
{
path = path.Substring(0, found);
}
try
{
foreach (string File in Directory.GetFiles(path + #"\Res\Patterns\", "*.xml"))
{
found = (short)File.LastIndexOf(#"\");
if (found > -1)
//... use files found
and the directory of files is present in both machines under Dir3, so it is found on the other machine but not on mine. I can't find any information on when and where Windows decides to return the forward slash (like a URL path) vs. the UNC path using "\". Why would this code work differently on different machines?
I am guessing that the path you simplified to C:\\Dir1\\Dir2\\Dir3/bin/debug actually had a hash (#) in the Dir3 name.
This is a quirk with Application.ExecutablePath apparently. You can use Assembly.GetEntryAssembly().Location instead, which returns consistent results.
I've added: using System.Data.Entity;
and now I don't get an error on compilation of this:
var k = db.Countries.Include(e => e.Cities);
but I still have to manually go into the database schema and check the current table correct name and copy-paste/type it in the code.
There is no IntelliSense after I use the period:
var k = db.Countries.Include(e => e.
So, the purpose of all this is questionable since it doesn't really help at all. Typing manually the table name (entity set name) in quotation marks isn't any different than typing it in a lambda expression - except for it is shorter as a string.
Hints?
Seems like your problem will be resolved when you add
using System.Data.Entity;
to top of your page
Seems like the problem is in ReSharper 6 IntelliSense. After turning off ReSharper 6 IntelliSense, the original VS2010 IntelliSense works fine. The bug has been reported.
I've tried everything I can think of to change the rendering parameters for a report that I need to render as a 300ppi TIFF.
Here's one of several attempts using the URL approach. As we went from 96ppi to 300ppi the size of the 8.5 x 11 image increases dramatically, but the resolution remainded at 96ppi.
//s0550284/ReportServer?/ERecordingReports/Report1&rs:Format=IMAGE&rc:DpiX=300&rc:DpiY=300&rc:PageHeight=11in&rc:PageWidth=8.5in&rs:Command=Render
We've tried changing the SSRS configuration files to change the default from 96ppi to 300ppi, but the change is ignored.
It's starting to look like someone hardcoded 96ppi somewhere where it can't be overridden.
We're running SQL Server 2008 R2.
Any thoughts about how to get past this problem would be very much appreciated.
-Tom
With the assistance of respondants here and in other forums, I found a simple hack that seems to solve my problem. It came to me after I gave up the fight with SSRS. I'm sure that there are lots of perfectly valid reasons as to why SSRS handles different resolution parameters as it does. Frankly, I don't give a hoot. I just need my document generated at the size and resolution I specified.
Here's the relevant pieces of code (error handling removed for the sake of brevity). I invoke SSRS via the web service interface, generate the report, and render it as 300 x 300 TIFF. The results are temporarily saved. It will have been generated as a 96ppi TIFF and scaled up. I then read it in into a BitMap, change the resolution to 300 x 300, and write it back out again. Done.
string deviceInfo = "<DeviceInfo> <OutputFormat>TIFF</OutputFormat> <DpiX>300</DpiX> <DpiY>300</DpiY> <PrintDpiX>300</PrintDpiX> <PrintDpiY>300</PrintDpiY> </DeviceInfo>";
string format = "IMAGE";
Byte[] results;
string mimeType = "image/tiff";
// Generate the report as a TIF
ExecutionInfo ei = new ExecutionInfo();
ei = rsExec.LoadReport(_reportName, historyID);
results = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
string TempFileRSGeneratedTIFF = TempPath + "RSGeneratedTIFF.TIF";
// Save tiff file returned by RS
using (FileStream stream = File.OpenWrite(TempFileRSGeneratedTIFF))
{
stream.Write(results, 0, results.Length);
}
// Read tif file into bitmap
Bitmap image = new Bitmap(TempFileRSGeneratedTIFF);
// Change the resolution to what it was supposed to be in the first place..
image.SetResolution(300, 300);
// Save the final version of the file
image.Save(DestFileName, System.Drawing.Imaging.ImageFormat.Tiff);
image.Dispose();
I was able to do this easily in SSRS 2008 R2 by editing the rsreportserver.config file:
<Extension Name="IMAGE" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering" />
<Extension Name="TIFF 200 DPI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
<OverrideNames>
<Name Language="en-US">TIFF 200 DPI</Name>
</OverrideNames>
<Configuration>
<DeviceInfo>
<ColorDepth>32</ColorDepth>
<DpiX>200</DpiX>
<DpiY>200</DpiY>
<OutputFormat>TIFF</OutputFormat>
</DeviceInfo>
</Configuration>
</Extension>
<Extension Name="TIFF 300 DPI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
<OverrideNames>
<Name Language="en-US">TIFF 300 DPI</Name>
</OverrideNames>
<Configuration>
<DeviceInfo>
<ColorDepth>32</ColorDepth>
<DpiX>300</DpiX>
<DpiY>300</DpiY>
<OutputFormat>TIFF</OutputFormat>
</DeviceInfo>
</Configuration>
</Extension>
Note that I left the original IMAGE extension intact (although I didn't have to) and added two more references to that extension - one at 200 DPI and one at 300 DPI. All three now show up in the export drop down list in Report Manager and work correctly. Note that (by following Micorsoft's example) I included the ColorDepth attribute although SSRS ignores it. Also note that I used the Language parameter in the Name attribute. The article I was looking at says that the override configuration will be ignored if it doesn't include the Language parameter (didn't test it).
I tried #Chuck Brevitt's method, but Reporting Services from the Web API didn't seem to be honouring the DPI settings for PDF settings.
I found by experimentation and some hints in Microsoft notes that this worked:
In order to get better PDF rendering of Images, pass the Device Info like this:
http://serverName/ReportServer?/pathtoReport/ReportName&InvoiceIdOrOtherParameter=24013&rs:Command=Render&rs:Format=PDF&rs:DeviceInfo=<DpiX>300<%2FDpiX><DpiY>300<%2FDpiY>
Try restarting your ReportServer after making the changes in the configuration file. Follow the below link.
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/2b1379e1-cbc5-4764-8f39-f043b334244d/rendering-a-report-in-tiff-at-300ppi?forum=sqlreportingservices
I am not quite sure about trying to change the resolution once you have the image exported.
Setup the image object to be external (link on report server) or in the database, versus embedded within the report.
I tried everything under the sun for SSRS 2012, and I mean everything. But eventually I gave up on it as well. Along the same lines of Tom and a ton of googling I found http://csharphelper.com/blog/2017/09/change-image-resolution-c/
This is the working model:
public static string BumpUpResolution(string filename, float dpiX, float dpiY, string processID)
{
int oldWidth = 0, oldHeight = 0;
Bitmap image = new Bitmap(filename);
oldWidth = image.Width;
oldHeight = image.Height;
using (Bitmap bm = new Bitmap(oldWidth, oldHeight))
{
Point[] points = {
new Point(0,0),
new Point(oldWidth, 0),
new Point(0, oldHeight),
};
using (Graphics gr = Graphics.FromImage(bm))
{
gr.DrawImage(image, points);
}
bm.SetResolution(dpiX, dpiY);
bm.Save(Path.Combine(Path.GetDirectoryName(filename), string.Format("{0}{1}", processID, Path.GetExtension(filename))), System.Drawing.Imaging.ImageFormat.Tiff);
}
image.Dispose();
return Path.Combine(Path.GetDirectoryName(filename), string.Format("{0}{1}", processID, Path.GetExtension(filename)));
}