From dbbbb5b6a0ef8c936b52411fe40afeb8483f5b7c Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Tue, 27 Aug 2024 19:52:48 -0400 Subject: [PATCH 1/4] Fix issue in attribute line with attribute class name --- .../CSharpAPIParser/TreeToken/CodeFileBuilder.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs index 15577766c82..bcda3b39cf6 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs @@ -517,8 +517,10 @@ private void BuildAttributes(List reviewLines, ImmutableArray Date: Tue, 27 Aug 2024 22:09:00 -0400 Subject: [PATCH 2/4] Fix attribute with bar seperator --- .../CSharpAPIParser/TreeToken/CodeFileBuilder.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs index bcda3b39cf6..8e253a3998e 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs @@ -575,7 +575,7 @@ private void BuildTypedConstant(ReviewLine reviewLine, TypedConstant typedConsta } else if (typedConstant.Kind == TypedConstantKind.Array) { - tokenList.Add(ReviewToken.CreateKeywordToken(SyntaxKind.NewKeyword, false)); + tokenList.Add(ReviewToken.CreateKeywordToken(SyntaxKind.NewKeyword)); tokenList.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.OpenBracketToken, false)); tokenList.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.CloseBracketToken)); tokenList.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.OpenBraceToken)); @@ -828,7 +828,9 @@ protected override void AddSpace() protected override void AddBitwiseOr() { - _tokenList.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.BarToken, false)); + if(_tokenList.Count > 0) + _tokenList.Last().HasSuffixSpace = true; + _tokenList.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.BarToken)); } public override void VisitField(IFieldSymbol symbol) From 0b05b67b5d94b344662983c0ac57c1669ddf19f9 Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Tue, 27 Aug 2024 23:18:49 -0400 Subject: [PATCH 3/4] Fix dispaly of template class name --- .../TreeToken/CodeFileBuilder.cs | 3 +-- .../CSharpAPIParserTests.csproj | 1 + .../CSharpAPIParserTests/CodeFileTests.cs | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs index 8e253a3998e..90969cee2e6 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs @@ -298,9 +298,7 @@ private void BuildType(List reviewLines, INamedTypeSymbol namedType, { typeToken.NavigationDisplayName = namedType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat); typeToken.RenderClasses.Add(namedType.TypeKind.ToString().ToLowerInvariant()); - typeToken.HasSuffixSpace = true; } - if (namedType.TypeKind == TypeKind.Delegate) { reviewLine.Tokens.Last().HasSuffixSpace = false; @@ -309,6 +307,7 @@ private void BuildType(List reviewLines, INamedTypeSymbol namedType, return; } + reviewLine.Tokens.Last().HasSuffixSpace = true; BuildBaseType(reviewLine, namedType); reviewLine.Tokens.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.OpenBraceToken)); foreach (var namedTypeSymbol in SymbolOrderProvider.OrderTypes(namedType.GetTypeMembers())) diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParserTests/CSharpAPIParserTests.csproj b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParserTests/CSharpAPIParserTests.csproj index 466c9d34132..006456c6bc2 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParserTests/CSharpAPIParserTests.csproj +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParserTests/CSharpAPIParserTests.csproj @@ -11,6 +11,7 @@ + diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParserTests/CodeFileTests.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParserTests/CodeFileTests.cs index 672a506a914..b4160e43a86 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParserTests/CodeFileTests.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParserTests/CodeFileTests.cs @@ -345,5 +345,25 @@ public void VerifyObsoleteMemberIsHidden() Assert.True(relatedLine?.IsHidden); } } + + [Fact] + public void VerifyTemplateClassLine() + { + var coreExprAssembly = Assembly.Load("Azure.Core.Expressions.DataFactory"); + var dllStream = coreExprAssembly.GetFile("Azure.Core.Expressions.DataFactory.dll"); + var assemblySymbol = CompilationFactory.GetCompilation(dllStream, null); + var codeFile = new CSharpAPIParser.TreeToken.CodeFileBuilder().Build(assemblySymbol, true, null); + + var lines = codeFile.ReviewLines; + var namespaceLine = lines.Where(lines => lines.LineId == "Azure.Core.Expressions.DataFactory").FirstOrDefault(); + Assert.NotNull(namespaceLine); + var classLine = namespaceLine.Children.Where(lines => lines.LineId.StartsWith("Azure.Core.Expressions.DataFactory.DataFactoryElement")).FirstOrDefault(); + Assert.NotNull(classLine); + Assert.Equal("public sealed class DataFactoryElement {", classLine.ToString().Trim()); + + var methodLine = classLine.Children.Where(lines => lines.LineId == "Azure.Core.Expressions.DataFactory.DataFactoryElement.FromKeyVaultSecret(Azure.Core.Expressions.DataFactory.DataFactoryKeyVaultSecret)").FirstOrDefault(); + Assert.NotNull(methodLine); + Assert.Equal("public static DataFactoryElement FromKeyVaultSecret(DataFactoryKeyVaultSecret secret);", methodLine.ToString().Trim()); + } } } From 8e7f2eef92ad0d037fc6ca72b5a45a1f4617c458 Mon Sep 17 00:00:00 2001 From: Praveen Kuttappan Date: Wed, 28 Aug 2024 12:25:25 -0400 Subject: [PATCH 4/4] Update parser version to 29.1 --- .../APIView/APIViewWeb/Languages/CSharpLanguageService.cs | 2 +- .../CSharpAPIParser/TreeToken/CodeFileBuilder.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dotnet/APIView/APIViewWeb/Languages/CSharpLanguageService.cs b/src/dotnet/APIView/APIViewWeb/Languages/CSharpLanguageService.cs index d8706bec0ce..131e8f9f8d8 100644 --- a/src/dotnet/APIView/APIViewWeb/Languages/CSharpLanguageService.cs +++ b/src/dotnet/APIView/APIViewWeb/Languages/CSharpLanguageService.cs @@ -17,7 +17,7 @@ public class CSharpLanguageService : LanguageProcessor public override string Name { get; } = "C#"; public override string[] Extensions { get; } = { ".dll" }; public override string ProcessName => _csharpParserToolPath; - public override string VersionString { get; } = "29"; + public override string VersionString { get; } = "29.1"; public CSharpLanguageService(IConfiguration configuration, TelemetryClient telemetryClient) : base(telemetryClient) { diff --git a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs index 90969cee2e6..5853a16aed9 100644 --- a/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs +++ b/tools/apiview/parsers/csharp-api-parser/CSharpAPIParser/TreeToken/CodeFileBuilder.cs @@ -47,7 +47,7 @@ public class CodeFileBuilder public ICodeFileBuilderSymbolOrderProvider SymbolOrderProvider { get; set; } = new CodeFileBuilderSymbolOrderProvider(); - public const string CurrentVersion = "29"; + public const string CurrentVersion = "29.1"; private IEnumerable EnumerateNamespaces(IAssemblySymbol assemblySymbol) {