@@ -292,6 +292,25 @@ public void TestMethod(string path, string password)
292292 GetCSharpResultAt ( 11 , 9 , 9 , 24 , "X509Certificate.X509Certificate(byte[] rawData, string password)" , "void TestClass.TestMethod(string path, string password)" , "byte[]" , "void TestClass.TestMethod(string path, string password)" ) ) ;
293293 }
294294
295+ [ Fact ]
296+ public void Test_X509Certificates2_Diagnostic ( )
297+ {
298+ VerifyCSharp ( @"
299+ using System.IO;
300+ using System.Security.Cryptography.X509Certificates;
301+
302+ class TestClass
303+ {
304+ public void TestMethod(string path)
305+ {
306+ byte[] bytes = new byte[] {1, 2, 3};
307+ File.WriteAllBytes(path, bytes);
308+ new X509Certificate2(path);
309+ }
310+ }" ,
311+ GetCSharpResultAt ( 11 , 9 , 9 , 24 , "X509Certificate2.X509Certificate2(string fileName)" , "void TestClass.TestMethod(string path)" , "byte[]" , "void TestClass.TestMethod(string path)" ) ) ;
312+ }
313+
295314 // For now, we didn't take serialization into consideration.
296315 [ Fact ]
297316 public void Test_Sink_X509Certificate_WithSerializationInfoAndStreamingContextParameters_NoDiagnostic ( )
@@ -347,6 +366,23 @@ public void TestMethod(string s, string path)
347366}" ) ;
348367 }
349368
369+ [ Fact ]
370+ public void Test_X509Certificate2_NoDiagnostic ( )
371+ {
372+ VerifyCSharp ( @"
373+ using System.IO;
374+ using System.Security.Cryptography.X509Certificates;
375+
376+ class TestClass
377+ {
378+ public void TestMethod(byte[] bytes, string path)
379+ {
380+ File.WriteAllBytes(path, bytes);
381+ new X509Certificate2(path);
382+ }
383+ }" ) ;
384+ }
385+
350386 protected override DiagnosticAnalyzer GetBasicDiagnosticAnalyzer ( )
351387 {
352388 return new DoNotHardCodeCertificate ( ) ;
0 commit comments