public void WithMultipleReturns(int returnAt) { // This is compiled such that each return statement essentially becomes // a branch to the very last ret statement TestMessages.Record("VoidMethodWithMultipleReturns: Body - 0"); if (returnAt == 1) { return; } TestMessages.Record("VoidMethodWithMultipleReturns: Body - 1"); if (returnAt == 2) { return; } TestMessages.Record("VoidMethodWithMultipleReturns: Body - 2"); if (returnAt == 3) { return; } TestMessages.Record("VoidMethodWithMultipleReturns: Body - 3"); }
public void ConditionallyThrowingInvalidOperationException(bool shouldThrow) { TestMessages.Record("VoidMethodConditionallyThrowingInvalidOperationException: Body"); if (shouldThrow) { throw new InvalidOperationException("Ooops"); } TestMessages.Record("VoidMethodConditionallyThrowingInvalidOperationException: Body2"); }
public int MultipleReturnValuesButWithEmbeddedThrow(int returnAt) { TestMessages.Record("MultipleReturnValuesButWithEmbeddedThrow: Body - 0"); if (returnAt == 1) { return(42); } TestMessages.Record("MultipleReturnValuesButWithEmbeddedThrow: Body - 1"); if (returnAt == 2) { throw new InvalidOperationException("Ooops"); } TestMessages.Record("MultipleReturnValuesButWithEmbeddedThrow: Body - 2"); return(164); }
public int MultipleReturns(int input) { TestMessages.Record("MultipleReturns: Body - 0"); if (input == 1) { return(7); } TestMessages.Record("MultipleReturns: Body - 1"); if (input == 2) { return(14); } TestMessages.Record("MultipleReturns: Body - 2"); return(input == 3 ? 21 : 28); }
public void MultipleReturnValuesButEndingWithThrow(int returnAt) { TestMessages.Record("MultipleReturnValuesButEndingWithThrow: Body - 0"); if (returnAt == 1) { return; } TestMessages.Record("MultipleReturnValuesButEndingWithThrow: Body - 1"); if (returnAt == 2) { return; } TestMessages.Record("MultipleReturnValuesButEndingWithThrow: Body - 2"); throw new InvalidOperationException("Ooops"); }
public void WithMultipleReturnsAndExceptions(int actAt, bool shouldThrow) { TestMessages.Record("WithMultipleReturnsAndExceptions: Body - 0"); if (actAt == 1) { if (shouldThrow) { throw new InvalidOperationException("Throwing at 1"); } return; } TestMessages.Record("WithMultipleReturnsAndExceptions: Body - 1"); if (actAt == 2) { if (shouldThrow) { throw new InvalidOperationException("Throwing at 2"); } return; } TestMessages.Record("WithMultipleReturnsAndExceptions: Body - 2"); if (actAt == 3) { if (shouldThrow) { throw new InvalidOperationException("Throwing at 3"); } return; } TestMessages.Record("WithMultipleReturnsAndExceptions: Body - 3"); }
public SimpleConstructor() { TestMessages.Record("InterceptingConstructors+SimpleConstructor: .ctor"); }
public int ReturnsNumber() { TestMessages.Record("ReturnsNumber: Body"); return(42); }
public string ReturnsString() { TestMessages.Record("ReturnsString: Body"); return("hello world"); }
public void OnEntry(MethodBase method) { TestMessages.Record(string.Format("OnEntry: {0}", method.DeclaringType.FullName + "." + method.Name)); }
public void OnException(MethodBase method, Exception exception) { TestMessages.Record(string.Format("OnException: {0} - {1}: {2}", method.DeclaringType.FullName + "." + method.Name, exception.GetType(), exception.Message)); }
public void WithoutArgs() { TestMessages.Record("VoidMethodWithoutArgs: Body"); }
public void ThrowingInvalidOperationException() { TestMessages.Record("VoidMethodThrowingInvalidOperationException: Body"); throw new InvalidOperationException("Ooops"); }
public static string ToTitleCase(this string value) { TestMessages.Record("ToTitleCase: In extension method"); return(new CultureInfo("en-GB", false).TextInfo.ToTitleCase(value)); }