Skip to content

Commit

Permalink
remove catch
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Feb 9, 2022
1 parent e32bf0a commit 7e0ec94
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions src/Compilers/Test/Core/CompilationVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,44 +268,32 @@ private void ILVerify(Verification verification)
return;
}

try
{
var resolver = new Resolver(_allModuleData);
var verifier = new ILVerify.Verifier(resolver);

var mscorlibModule = _allModuleData.Single(m => m.IsCorLib);
verifier.SetSystemModuleName(new AssemblyName(mscorlibModule.SimpleName));

// Main module is the first one
var result = verifier.Verify(resolver.Resolve(_allModuleData[0].SimpleName));
if (result.Count() == 0)
{
if ((verification & Verification.FailsILVerify) == 0)
{
return;
}
var resolver = new Resolver(_allModuleData);
var verifier = new ILVerify.Verifier(resolver);

throw new Exception("IL Verify succeeded unexpectedly");
}
var mscorlibModule = _allModuleData.Single(m => m.IsCorLib);
verifier.SetSystemModuleName(new AssemblyName(mscorlibModule.SimpleName));

if ((verification & Verification.FailsILVerify) != 0)
// Main module is the first one
var result = verifier.Verify(resolver.Resolve(_allModuleData[0].SimpleName));
if (result.Count() == 0)
{
if ((verification & Verification.FailsILVerify) == 0)
{
return;
}

string message = printVerificationResult(result);
throw new Exception("IL Verify failed unexpectedly: \r\n" + message);
throw new Exception("IL Verify succeeded unexpectedly");
}
catch (Exception)
{
if ((verification & Verification.FailsILVerify) != 0)
{
return;
}

throw;
if ((verification & Verification.FailsILVerify) != 0)
{
return;
}

string message = printVerificationResult(result);
throw new Exception("IL Verify failed unexpectedly: \r\n" + message);

static string printVerificationResult(IEnumerable<ILVerify.VerificationResult> result)
{
return string.Join("\r\n", result.Select(r => r.Message + printErrorArguments(r.ErrorArguments)));
Expand Down

0 comments on commit 7e0ec94

Please sign in to comment.