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 15577766c82..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) { @@ -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())) @@ -517,8 +516,10 @@ private void BuildAttributes(List reviewLines, ImmutableArray 0) + _tokenList.Last().HasSuffixSpace = true; _tokenList.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.BarToken)); } public override void VisitField(IFieldSymbol symbol) { - _tokenList.Add(ReviewToken.CreateTypeNameToken(symbol.Type.Name)); - _tokenList.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.DotToken)); - _tokenList.Add(ReviewToken.CreateMemberNameToken(symbol.Name)); + _tokenList.Add(ReviewToken.CreateTypeNameToken(symbol.Type.Name, false)); + _tokenList.Add(ReviewToken.CreatePunctuationToken(SyntaxKind.DotToken, false)); + _tokenList.Add(ReviewToken.CreateMemberNameToken(symbol.Name, false)); } public void Format(ITypeSymbol? type, object? typedConstantValue) 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()); + } } }