@@ -43,9 +43,9 @@ static CodeFileTests()
4343
4444 public static IEnumerable < object [ ] > CodeFiles => new List < object [ ] >
4545 {
46- new object [ ] { templateCodeFile , "Azure.Template" , "1.0.3.0" , 8 } ,
47- new object [ ] { storageCodeFile , "Azure.Storage.Blobs" , "12.21.2.0" , 14 } ,
48- new object [ ] { coreCodeFile , "Azure.Core" , "1.42.0.0" , 26 } ,
46+ new object [ ] { templateCodeFile , "Azure.Template" , "1.0.3.0" , 9 } ,
47+ new object [ ] { storageCodeFile , "Azure.Storage.Blobs" , "12.21.2.0" , 15 } ,
48+ new object [ ] { coreCodeFile , "Azure.Core" , "1.42.0.0" , 27 } ,
4949 } ;
5050
5151 [ Theory ]
@@ -103,6 +103,7 @@ public void TestApiReviewLine()
103103 var classLine = namespaceLine . Children . Where ( lines => lines . LineId == "Azure.Storage.Blobs.BlobServiceClient" ) . FirstOrDefault ( ) ;
104104 Assert . NotNull ( classLine ) ;
105105 var methodLine = classLine . Children . Where ( lines => lines . LineId == "Azure.Storage.Blobs.BlobServiceClient.BlobServiceClient(System.String)" ) . FirstOrDefault ( ) ;
106+ Assert . NotNull ( methodLine ) ;
106107 Assert . Equal ( 7 , methodLine . Tokens . Count ( ) ) ;
107108 Assert . Equal ( "public BlobServiceClient(string connectionString);" , methodLine . ToString ( ) . Trim ( ) ) ;
108109 }
@@ -224,7 +225,7 @@ public static class TemplateClientBuilderExtensions {
224225 public void TestCodeFileJsonSchema ( CodeFile codeFile )
225226 {
226227 //Verify JSON file generated for Azure.Template
227- var isValid = validateSchema ( templateCodeFile ) ;
228+ var isValid = validateSchema ( codeFile ) ;
228229 Assert . True ( isValid ) ;
229230 }
230231
@@ -261,6 +262,7 @@ public void TestNavigationNodeHasRenderingClass()
261262 {
262263 var jsonString = JsonSerializer . Serialize ( templateCodeFile ) ;
263264 var parsedCodeFile = JsonSerializer . Deserialize < CodeFile > ( jsonString ) ;
265+ Assert . NotNull ( parsedCodeFile ) ;
264266 Assert . Equal ( 8 , CountNavigationNodes ( parsedCodeFile . ReviewLines ) ) ;
265267 }
266268
@@ -317,5 +319,31 @@ private int CountHiddenApiInBlobDownloadInfo(List<ReviewLine> lines)
317319 }
318320 return count ;
319321 }
322+
323+ [ Fact ]
324+ public void VerifyObsoleteMemberIsHidden ( )
325+ {
326+ var attestationAssembly = Assembly . Load ( "Azure.Security.Attestation" ) ;
327+ var dllStream = attestationAssembly . GetFile ( "Azure.Security.Attestation.dll" ) ;
328+ var assemblySymbol = CompilationFactory . GetCompilation ( dllStream , null ) ;
329+ var codeFile = new CSharpAPIParser . TreeToken . CodeFileBuilder ( ) . Build ( assemblySymbol , true , null ) ;
330+
331+ var lines = codeFile . ReviewLines ;
332+ var namespaceLine = lines . Where ( lines => lines . LineId == "Azure.Security.Attestation" ) . FirstOrDefault ( ) ;
333+ Assert . NotNull ( namespaceLine ) ;
334+ var classLine = namespaceLine . Children . Where ( lines => lines . LineId == "Azure.Security.Attestation.AttestationResult" ) . FirstOrDefault ( ) ;
335+ Assert . NotNull ( classLine ) ;
336+
337+ var obsoleteMethods = classLine . Children . Where ( line => line . ToString ( ) . StartsWith ( "[Obsolete(" ) ) ;
338+ Assert . NotEmpty ( obsoleteMethods ) ;
339+ //Make sure member lines are marked as hidden if it has obsolete attribute
340+ foreach ( var method in obsoleteMethods )
341+ {
342+ Assert . True ( method . IsHidden ) ;
343+ Assert . NotNull ( method . RelatedToLine ) ;
344+ var relatedLine = classLine . Children . Where ( line => line . LineId == method . RelatedToLine ) . FirstOrDefault ( ) ;
345+ Assert . True ( relatedLine ? . IsHidden ) ;
346+ }
347+ }
320348 }
321349}
0 commit comments