UPDATE: After some research, i've found out that that's an issue with Visual Studio 2015 and Text Visualizer, which you can see here.
To reproduce it, Open QuickWatch (Shift+F9) and in the search box, put new string(' ', 32769)
. After that click at the magnifier glass and you should see a "..." in the middle of the string...
So, changing my question, is there a way to fix this and make it not truncate, so i can copy without workarounds?
I have this piece of code:
JArray bundlesJson = (JArray)JObject.Parse(System.IO.File.ReadAllText(Server.MapPath("~/itens.json")))["bundles"]; // file "itens.json" can be found at http://pastebin.com/7K15yAVd
System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex(@"(?<sNome>.*?)\/(?<sClasse>.*?)\/(?<sDescricao>.*?)(?:\/(?<sExtras>.*?)\n|\n|$)");
var text = System.IO.File.ReadAllText(Server.MapPath("~/TextFile1.txt")); // TextFile1.txt is too big to put here, so i've uploaded it here: http://pastebin.com/AtxbYPXc
var matches = rgx.Matches(text);
var lstItens = new List<Item>();
var oJson = new JArray();
foreach (System.Text.RegularExpressions.Match match in matches)
{
var item = new Item()
{
sClasse = match.Groups["sClasse"].Value.Trim(),
sDescricao = match.Groups["sDescricao"].Value.Trim(),
sNome = match.Groups["sNome"].Value.Trim(),
sExtras = match.Groups["sExtras"].Value.Trim(),
};
item.PreencherListaBundles(bundlesJson.ToString());
lstItens.Add(item);
}
var result = JsonConvert.SerializeObject(lstItens, Formatting.Indented);
var backResult = JsonConvert.DeserializeObject<List<Item>>(result);
The lstItens
list has all items correctly (501 items), but the result
string returns only 48 objects when searched for "Nome":
, which is a mandatory field. Why is this happening?
To exemplify the error, look for the item lstItens[166]
, in the result
var, if you search for "Nome": "Fiddlehead Fern"
you can see that the item doesn't exists...
What is weird is that backResult.Count
will show 501 results, and appears to have every item, but a simple search in the json generated at the result
var using a mandatory field "Nome" will result in 48 results, as showed in the image :
Item.cs:
public class Item
{
[JsonProperty(PropertyName = "Nome")]
public string sNome { get; set; }
[JsonProperty(PropertyName = "Classe")]
public string sClasse { get; set; }
[JsonProperty(PropertyName = "Descricao")]
public string sDescricao { get; set; }
[JsonProperty(PropertyName = "Extras")]
public string sExtras { get; set; }
[JsonProperty(PropertyName = "Bundles")]
public List<Bundle> lstBundles { get; set; }
public void PreencherListaBundles(string jsonBundles)
{
List<Bundle> lstBundle = JsonConvert.DeserializeObject<List<Bundle>>(jsonBundles.ToString());
this.lstBundles = new List<Bundle>();
lstBundle.ForEach(x =>
{
if (!lstBundles.Select(y => y.sNome).Contains(x.sNome) && x.lstItens.Select(y => y.sNome).Contains(sNome))
{
lstBundles.Add(new Bundle() { sLocal = x.sLocal, sNome = x.sNome, sRecompensa = x.sRecompensa, lstItens = x.lstItens });
}
});
}
}
Bundle.cs
public class Bundle
{
[JsonProperty(PropertyName = "bundle")]
public string sNome { get; set; }
[JsonProperty(PropertyName = "location")]
public string sLocal { get; set; }
[JsonProperty(PropertyName = "reward")]
public string sRecompensa { get; set; }
[JsonProperty(PropertyName = "items")]
public List<BundleItem> lstItens { get; set; }
public class BundleItem
{
[JsonProperty(PropertyName = "name")]
public string sNome { get; set; }
[JsonProperty(PropertyName = "description")]
public string sDescricao { get; set; }
[JsonProperty(PropertyName = "quantity")]
public int nQuantidade { get; set; }
[JsonProperty(PropertyName = "quality")]
public string sQualidade { get; set; }
}
}
EDIT: Looks like that bug is not happening on some machines, like you can see with the Gerard Sexton's answer, but when i run the same code he ran i still get the 48 results. some more details can be found in this discussion: https://chat.stackoverflow.com/rooms/106307/discussion-between-gerard-sexton-and-gabriel-duarte