Skip to content

Commit b7b5f95

Browse files
Serve APIView Index Page and Review Page Via SPA UI (#8502)
Good Rebase Add client SPA APIView V2 index page Sort by lastUpdated on, stop scrolling when end is reached Geting Revisions list working fine Fix dynamic height calculation for revisions table Fix APIRevisions filters Soft Delete of APIRevisions working Implement Review Creation File Upload Implemented APIView V@ Index Page Working APIViewV2 Index PAge Working Add Option in Profile for Beta UI Enable SPA deployment Update Assets Path Remove Console Logs Add Filter for Showing Reviews Aprroved for First Release Update First Release apporval indicator Update ARIRevision Filters Improvements to Requested Review Page Implement Release time Config Update First Release Approval Filters Store filters in cookies Update to TokenTree CodeFile Retrieve APITree from LeanControllers Implement CodeLines Tokens Displayed in UI Like trees Add Comments Add Comment Threads Comments Partially Implemented implement Diffing Add Logic for Diffing APITree Token Diff COmputation Work on CodeLines Compute Diff on Client Side Lazy Load Modules Move workers into services Split workers into separate files Start Implementing Lazy Loading Lazy Loading Implemented Upgrade APP to PWA Configure MIME type Pseudo Lazy Loading Pseudo Lazy Loading Show Review Page Navigation Lazy Loading CodeLines Partially working Add ShowDocumentation Button Show / Hide Documentation Fix API for Swagger Diagnostics Comment Add Review Page Options Add APIRevision Dropdowns Add Redirection to SPA UI terminate worker after 5 seconds of inactivity Capture user comments Templating for comments Add Markdown support to Comments Complete Templating for Comments Regular Diffind with lazy loaded lines Add Comparere for APITreeNode Making diff smarter Move dropdown to top left Reload Revisions smoothly Improvements to tree navigation Navigation Icons documentation buttons Documentation and Comments Show page settings Add Page Settings Show Only Diff working Show only diff working increase component budget Show Comment Setting Cache pre-flight requests for about a day Hide comments on toggle toggle Page Options Cahce http requests for content for one day Adjust Service WOrker ROute Service worker Registration Remove angular service worker Install workbox Register Workbox service worker Register Service Worker Sending from Client Side Diff working for Demo Build Code Panel Data on client side Build Code Panel Data on CLient Side Build tree on Server Build Tree On the Server Build Tree Nodes in Parallel Move Diff to Server Side Compute Diff on Server Side Show Page Navigation Fix navigation padding Working on diff style Add Diff Style Dropdown Diff Styles Partially Working Retrieve MessagePack Retrieve Message Pack Object Handle API Errors Render Space Tokens Properly Check Redirect Attempt to Improve Serialized JSON Size Eliminate empty collections from serialization Get Angular UI working Adjust Json Serialization properties Support paralleism only for multicore processors, and avoid thread starvation Jump to Navigation Add Marked As Viewd Feature Add MessagePack Serialization testing out MessagePack Add Change Histroy Switch to System.Text.Json Approval Options Ensure Diff Style is working Update Redirect to SPA and APIRevision Selection Updates to Comments Comment API Calls Set ParserStyle Modify nodeIdHashed algorithm Update Json Property Names Deserialize using gzip Update Java Icons Update Build Pipeline Add and Save Comments Add and Save Comments Left navigation toggling Toggle Left Navigation Comment Resolution Hide Line Numbers switch connected and working (#8462) * Hide Line Numbers switch connected and working * Show Line Number Switch Torubleshooting * Show Line Number Persisting but values are switched * Line Number Switch toggling correctly and changes persisting * Removed console.log Toggling of UpVotes Request Reviewers Work on Approval Buttons Page Navigation Token Navigation Support TreeStle Parser In Language Services Install dotnet Tool during App Deployment Add tool path durign deployment, enable code faile comparison for tree style codeFiles Rework comments to work across multi lines nodes Resolve PR comments Add Dependencies icon Index PAge based on User Preference adjusting Panel Sizes Propagate diff kind to node descendants ADd Back Icons Address Issues Raised in Pull Requests
1 parent de379c3 commit b7b5f95

File tree

246 files changed

+28158
-462
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+28158
-462
lines changed

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"class-transformer": "^0.5.1"
4+
}
5+
}

src/dotnet/APIView/APIView/Model/CodeFile.cs

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,32 @@
66
using System;
77
using System.Collections.Generic;
88
using System.IO;
9+
using System.IO.Compression;
910
using System.Linq;
1011
using System.Text.Json;
12+
using System.Text.Json.Serialization;
1113
using System.Threading.Tasks;
1214

1315
namespace ApiView
1416
{
1517
public class CodeFile
1618
{
17-
private static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions()
19+
private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions
1820
{
1921
AllowTrailingCommas = true,
2022
ReadCommentHandling = JsonCommentHandling.Skip
2123
};
2224

25+
private static readonly JsonSerializerOptions _treeStyleParserDeserializerOptions = new JsonSerializerOptions
26+
{
27+
Converters = { new StructuredTokenConverter() }
28+
};
29+
30+
private static readonly JsonSerializerOptions _treeStyleParserSerializerOptions = new JsonSerializerOptions
31+
{
32+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
33+
};
34+
2335
private string _versionString;
2436
private static HashSet<string> _collapsibleLanguages = new HashSet<string>(new string[] { "Swagger" });
2537
[Obsolete("This is only for back compat, VersionString should be used")]
@@ -49,11 +61,21 @@ public override string ToString()
4961
return new CodeFileRenderer().Render(this).CodeLines.ToString();
5062
}
5163
public static bool IsCollapsibleSectionSSupported(string language) => _collapsibleLanguages.Contains(language);
52-
public static async Task<CodeFile> DeserializeAsync(Stream stream, bool hasSections = false)
64+
65+
public static async Task<CodeFile> DeserializeAsync(Stream stream, bool hasSections = false, bool doTreeStyleParserDeserialization = false)
5366
{
54-
var codeFile = await JsonSerializer.DeserializeAsync<CodeFile>(
55-
stream,
56-
JsonSerializerOptions);
67+
CodeFile codeFile = null;
68+
if (doTreeStyleParserDeserialization)
69+
{
70+
using (var gzipStream = new GZipStream(stream, CompressionMode.Decompress, leaveOpen: true))
71+
{
72+
codeFile = await JsonSerializer.DeserializeAsync<CodeFile>(gzipStream, _treeStyleParserDeserializerOptions);
73+
}
74+
}
75+
else
76+
{
77+
codeFile = await JsonSerializer.DeserializeAsync<CodeFile>(stream, _serializerOptions);
78+
}
5779

5880
if (hasSections == false && codeFile.LeafSections == null && IsCollapsibleSectionSSupported(codeFile.Language))
5981
hasSections = true;
@@ -129,10 +151,23 @@ public static async Task<CodeFile> DeserializeAsync(Stream stream, bool hasSecti
129151

130152
public async Task SerializeAsync(Stream stream)
131153
{
132-
await JsonSerializer.SerializeAsync(
133-
stream,
134-
this,
135-
JsonSerializerOptions);
154+
if (this.APIForest.Count > 0)
155+
{
156+
using (var tempStream = new MemoryStream())
157+
{
158+
await JsonSerializer.SerializeAsync(tempStream, this, _treeStyleParserSerializerOptions);
159+
tempStream.Position = 0;
160+
161+
using (var compressionStream = new GZipStream(stream, CompressionMode.Compress, leaveOpen: true))
162+
{
163+
await tempStream.CopyToAsync(compressionStream);
164+
}
165+
}
166+
}
167+
else
168+
{
169+
await JsonSerializer.SerializeAsync(stream, this, _serializerOptions);
170+
}
136171
}
137172
}
138173
}

src/dotnet/APIView/APIView/Model/StructuredTokenModel.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using Microsoft.CodeAnalysis;
33
using Microsoft.CodeAnalysis.CSharp;
44
using System.Text.Json.Serialization;
5+
using System.Text.Json;
6+
using System;
57

68
namespace APIView.TreeToken
79
{
@@ -35,6 +37,52 @@ public enum StructuredTokenKind
3537
ParameterSeparator = 4
3638
}
3739

40+
public enum DiffKind
41+
{
42+
NoneDiff = 0,
43+
Unchanged = 1, // Unchanged means the top level node is the same, the children could still contain diffs.
44+
Added = 2,
45+
Removed = 3
46+
}
47+
48+
public class StructuredTokenConverter : JsonConverter<StructuredToken>
49+
{
50+
private readonly string _parameterSeparator;
51+
52+
public StructuredTokenConverter(string parameterSeparator = "\u00A0")
53+
{
54+
_parameterSeparator = parameterSeparator;
55+
}
56+
57+
public override StructuredToken Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
58+
{
59+
var jObject = JsonDocument.ParseValue(ref reader).RootElement;
60+
var myObject = JsonSerializer.Deserialize<StructuredToken>(jObject.GetRawText());
61+
62+
switch (myObject.Kind)
63+
{
64+
case StructuredTokenKind.LineBreak:
65+
myObject.Value = "\u000A";
66+
break;
67+
case StructuredTokenKind.NonBreakingSpace:
68+
myObject.Value = "\u00A0";
69+
break;
70+
case StructuredTokenKind.TabSpace:
71+
myObject.Value = "\u00A0\u00A0\u00A0\u00A0";
72+
break;
73+
case StructuredTokenKind.ParameterSeparator:
74+
myObject.Value = _parameterSeparator;
75+
break;
76+
}
77+
return myObject;
78+
}
79+
80+
public override void Write(Utf8JsonWriter writer, StructuredToken value, JsonSerializerOptions options)
81+
{
82+
JsonSerializer.Serialize(writer, value, options);
83+
}
84+
}
85+
3886
/// <summary>
3987
/// Represents an APIView token its properties and tags for APIView parsers.
4088
/// </summary>
@@ -193,6 +241,21 @@ public StructuredToken(string value)
193241
Value = value;
194242
Kind = StructuredTokenKind.Content;
195243
}
244+
public StructuredToken(StructuredToken token)
245+
{
246+
Value = token.Value;
247+
Id = token.Id;
248+
Kind = token.Kind;
249+
foreach (var property in token.PropertiesObj)
250+
{
251+
PropertiesObj.Add(property.Key, property.Value);
252+
}
253+
foreach (var renderClass in token.RenderClassesObj)
254+
{
255+
RenderClassesObj.Add(renderClass);
256+
}
257+
}
258+
196259

197260
public static StructuredToken CreateLineBreakToken()
198261
{

src/dotnet/APIView/APIView/Model/TokenTreeModel.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,16 @@ public List<StructuredToken> TopTokens
149149

150150
[JsonIgnore]
151151
public List<APITreeNode> ChildrenObj { get; set; } = new List<APITreeNode>();
152-
152+
153+
[JsonIgnore]
154+
public DiffKind DiffKind { get; set; } = DiffKind.NoneDiff;
155+
156+
[JsonIgnore]
157+
public List<StructuredToken> TopDiffTokens { get; set; } = new List<StructuredToken>();
158+
159+
[JsonIgnore]
160+
public List<StructuredToken> BottomDiffTokens { get; set; } = new List<StructuredToken>();
161+
153162
public override int GetHashCode()
154163
{
155164
int hash = 17;

src/dotnet/APIView/APIViewIntegrationTests/TestsBaseFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public TestsBaseFixture()
134134
authorizationService: authorizationServiceMoq.Object, reviewsRepository: ReviewRepository,
135135
apiRevisionsManager: APIRevisionManager, commentManager: CommentsManager, codeFileRepository: BlobCodeFileRepository,
136136
commentsRepository: CommentRepository, languageServices: languageService, signalRHubContext: signalRHubContextMoq.Object,
137-
telemetryClient: telemetryClient.Object);
137+
telemetryClient: telemetryClient.Object, codeFileManager: CodeFileManager);
138138

139139
TestDataPath = _config["TestPkgPath"];
140140
}

0 commit comments

Comments
 (0)