From a8ae2e3d99a33a0ff97a355db9c98cd4507f04b8 Mon Sep 17 00:00:00 2001 From: tom-englert Date: Fri, 5 Feb 2016 20:00:50 +0100 Subject: [PATCH] Add null check to avoid crash when parsing Roslyn generated code. --- Microsoft.Research/CCDoc/XContract.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Microsoft.Research/CCDoc/XContract.cs b/Microsoft.Research/CCDoc/XContract.cs index 4159015d..fe28e3ee 100644 --- a/Microsoft.Research/CCDoc/XContract.cs +++ b/Microsoft.Research/CCDoc/XContract.cs @@ -606,6 +606,8 @@ namespace CCDoc { var n = methodCall.Arguments.Count(); if (n == 2) { var lambda = methodCall.Arguments.ElementAt(1) as IAnonymousDelegate; + if (lambda == null) + return; sourceEmitterOutput.Write(lambda.Parameters.ElementAt(0).Name.Value); sourceEmitterOutput.Write(" in "); Traverse(methodCall.Arguments.ElementAt(0)); @@ -615,6 +617,8 @@ namespace CCDoc { } else { // n == 3 var lambda = methodCall.Arguments.ElementAt(2) as IAnonymousDelegate; + if (lambda == null) + return; var paramName = lambda.Parameters.ElementAt(0).Name.Value; sourceEmitterOutput.Write(paramName); sourceEmitterOutput.Write(" where ");