|
15 | 15 | using System.Net.Http;
|
16 | 16 | using System.Net.Mail;
|
17 | 17 | using System.Reflection;
|
| 18 | +using System.Runtime.CompilerServices; |
18 | 19 | using System.Runtime.InteropServices;
|
19 | 20 | using System.Security.Cryptography;
|
20 | 21 | using System.Text;
|
@@ -150,6 +151,9 @@ public List<string> GetAspects()
|
150 | 151 | [InlineData(typeof(SmtpClient), "Send", new[] { "Void Send(System.String, System.String, System.String, System.String)" }, true)]
|
151 | 152 | [InlineData(typeof(SmtpClient), "SendAsync", new[] { "Void SendAsync(System.String, System.String, System.String, System.String, System.Object)" }, true)]
|
152 | 153 | [InlineData(typeof(SmtpClient), "SendMailAsync", new[] { "System.Threading.Tasks.Task SendMailAsync(System.String, System.String, System.String, System.String, System.Threading.CancellationToken)", "System.Threading.Tasks.Task SendMailAsync(System.String, System.String, System.String, System.String)" }, true)]
|
| 154 | +#if NET6_0_OR_GREATER |
| 155 | + [InlineData(typeof(DefaultInterpolatedStringHandler), null, new[] { "Void AppendFormatted(System.ReadOnlySpan`1[System.Char], Int32, System.String)" }, true)] |
| 156 | +#endif |
153 | 157 | [Trait("Category", "EndToEnd")]
|
154 | 158 | [Trait("RunOnWindows", "True")]
|
155 | 159 | public void TestMethodsAspectCover(Type typeToCheck, string methodToCheck, string[] overloadsToExclude = null, bool excludeParameterlessMethods = false)
|
@@ -305,6 +309,9 @@ public void TestFileClassMethodsAspectCover()
|
305 | 309 | [InlineData(typeof(Assembly))]
|
306 | 310 | #endif
|
307 | 311 | [InlineData(typeof(Assembly), new string[] { "System.Reflection.Assembly::Load(System.String,System.Security.Policy.Evidence)" })]
|
| 312 | +#if NET6_0_OR_GREATER |
| 313 | + [InlineData(typeof(DefaultInterpolatedStringHandler), null)] |
| 314 | +#endif |
308 | 315 | [Trait("Category", "EndToEnd")]
|
309 | 316 | [Trait("RunOnWindows", "True")]
|
310 | 317 | public void TestAllAspectsHaveACorrespondingMethod(Type type, string[] aspectsToExclude = null)
|
@@ -389,7 +396,7 @@ private string NormalizeName(string signature)
|
389 | 396 |
|
390 | 397 | return signature.Replace(" ", string.Empty).Replace("[T]", string.Empty).Replace("<!!0>", string.Empty)
|
391 | 398 | .Replace("[", "<").Replace("]", ">").Replace(",...", string.Empty).Replace("System.", string.Empty)
|
392 |
| - .Replace("ByRef", string.Empty); |
| 399 | + .Replace("ByRef", string.Empty).Replace("!!0", "T"); |
393 | 400 | }
|
394 | 401 |
|
395 | 402 | private bool MethodShouldBeChecked(MethodBase method)
|
@@ -445,7 +452,13 @@ private void TestMethodOverloads(Type typeToCheck, string methodToCheck, List<st
|
445 | 452 | Output.WriteLine("Checking: " + methodSignature);
|
446 | 453 | if (MethodShouldBeChecked(method) && overloadsToExcludeNormalized?.Contains(methodSignature) != true)
|
447 | 454 | {
|
448 |
| - var isCovered = aspects.Any(x => NormalizeName(x).Contains(methodSignature) && x.Contains(typeToCheck.FullName)); |
| 455 | + var isCovered = aspects.Any(x => |
| 456 | + { |
| 457 | + var normalized = NormalizeName(x); |
| 458 | + var contains = normalized.Contains(methodSignature); |
| 459 | + var xcontains = x.Contains(typeToCheck.FullName); |
| 460 | + return contains && xcontains; |
| 461 | + }); |
449 | 462 | isCovered.Should().BeTrue(method.ToString() + " is not covered");
|
450 | 463 | }
|
451 | 464 | }
|
|
0 commit comments