public Task <ServiceResponse <byte[]> > SendAnalysisAsync(AnalyzeRequest a, string format) { var sortedAnalyzeRequest = new AnalyzeRequest { RequestFlags = a.RequestFlags, Dependencies = a.Dependencies .OrderBy(t => t.Key.MemberDocId) .ThenBy(t => t.Key.TypeDocId) .ToDictionary(t => t.Key, t => t.Value.OrderBy(tt => tt.AssemblyIdentity).ToList() as ICollection <AssemblyInfo>), UnresolvedAssemblies = new SortedSet <string>(a.UnresolvedAssemblies, StringComparer.Ordinal), UnresolvedAssembliesDictionary = a.UnresolvedAssembliesDictionary .OrderBy(t => t.Key) .ToDictionary(t => t.Key, t => new SortedSet <string>(t.Value) as ICollection <string>), UserAssemblies = new SortedSet <AssemblyInfo>(a.UserAssemblies), AssembliesWithErrors = new SortedSet <string>(a.AssembliesWithErrors, StringComparer.Ordinal), Targets = new SortedSet <string>(a.Targets, StringComparer.Ordinal), ApplicationName = a.ApplicationName, Version = a.Version, BreakingChangesToSuppress = new SortedSet <string>(a.BreakingChangesToSuppress ?? Enumerable.Empty <string>(), StringComparer.Ordinal), AssembliesToIgnore = a.AssembliesToIgnore.OrderBy(i => i.AssemblyIdentity) }; var result = sortedAnalyzeRequest.Serialize(); return(Task.FromResult(ServiceResponse.Create(result))); }
private void WriteOutput(AnalyzeRequest a) { var sortedAnalyzeRequest = new AnalyzeRequest { RequestFlags = a.RequestFlags, Dependencies = a.Dependencies .OrderBy(t => t.Key.MemberDocId) .ThenBy(t => t.Key.TypeDocId) .ToDictionary(t => t.Key, t => t.Value.OrderBy(tt => tt.AssemblyIdentity).ToList() as ICollection <AssemblyInfo>), UnresolvedAssemblies = new SortedSet <string>(a.UnresolvedAssemblies, StringComparer.Ordinal), UnresolvedAssembliesDictionary = a.UnresolvedAssembliesDictionary .OrderBy(t => t.Key) .ToDictionary(t => t.Key, t => new SortedSet <string>(t.Value) as ICollection <string>), UserAssemblies = new SortedSet <AssemblyInfo>(a.UserAssemblies), AssembliesWithErrors = new SortedSet <string>(a.AssembliesWithErrors, StringComparer.Ordinal), Targets = new SortedSet <string>(a.Targets, StringComparer.Ordinal), ApplicationName = a.ApplicationName, Version = a.Version, BreakingChangesToSuppress = new SortedSet <string>(a.BreakingChangesToSuppress, StringComparer.Ordinal), AssembliesToIgnore = a.AssembliesToIgnore.OrderBy(i => i.AssemblyIdentity) }; var tmp = $"{Path.GetTempFileName()}.json"; using (var ms = new MemoryStream(sortedAnalyzeRequest.Serialize())) using (var fs = File.OpenWrite(tmp)) { ms.CopyTo(fs); } Process.Start(tmp); }
public void SerializeAnalyzeRequest() { var request = new AnalyzeRequest { ApplicationName = "name", Dependencies = GetDependencies(), Targets = new List <string> { "target1", "target2" }, UnresolvedAssemblies = new List <string> { "assembly1", "assembly2" }, UserAssemblies = new List <AssemblyInfo> { new AssemblyInfo { AssemblyIdentity = "name1" }, new AssemblyInfo { AssemblyIdentity = "name2" } }, Version = AnalyzeRequest.CurrentVersion }; var newtonsoft = request.Serialize().Deserialize <AnalyzeRequest>(); var dcjs = DeserializeObjectDcjs <AnalyzeRequest>(SerializeDcjs(request)); CompareAnalyzeRequest(request, newtonsoft); CompareAnalyzeRequest(request, dcjs); }
private byte[] SerializeRequest(AnalyzeRequest a) { var sortedAnalyzeRequest = new AnalyzeRequest { RequestFlags = a.RequestFlags, Dependencies = a.Dependencies .OrderBy(t => t.Key.MemberDocId) .ThenBy(t => t.Key.TypeDocId) .ToDictionary(t => t.Key, t => t.Value.OrderBy(tt => tt.AssemblyIdentity).ToList() as ICollection <AssemblyInfo>), UnresolvedAssemblies = new SortedSet <string>(a.UnresolvedAssemblies, StringComparer.Ordinal), UnresolvedAssembliesDictionary = a.UnresolvedAssembliesDictionary .OrderBy(t => t.Key) .ToDictionary(t => t.Key, t => new SortedSet <string>(t.Value) as ICollection <string>), NonUserAssemblies = new SortedSet <AssemblyInfo>(a.NonUserAssemblies), UserAssemblies = new SortedSet <AssemblyInfo>(a.UserAssemblies), AssembliesWithErrors = new SortedSet <string>(a.AssembliesWithErrors, StringComparer.Ordinal), Targets = new SortedSet <string>(a.Targets, StringComparer.Ordinal), ApplicationName = a.ApplicationName, Version = a.Version, BreakingChangesToSuppress = new SortedSet <string>(a.BreakingChangesToSuppress ?? Enumerable.Empty <string>(), StringComparer.Ordinal), AssembliesToIgnore = a.AssembliesToIgnore.OrderBy(i => i.AssemblyIdentity) }; return(sortedAnalyzeRequest.Serialize()); }