PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/base/Applications/Tests/ThrowWithLinkStack/ThrowWithLinkStack.cs

#
C# | 58 lines | 42 code | 7 blank | 9 comment | 0 complexity | a3e943b63acbf24a14b9182923a66370 MD5 | raw file
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft Research Singularity
  4. //
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. //
  7. // Note: Simple Singularity test program.
  8. //
  9. using System;
  10. using Microsoft.Singularity.V1.Services;
  11. using System.Runtime.CompilerServices;
  12. using Microsoft.Singularity.Channels;
  13. using Microsoft.Contracts;
  14. using Microsoft.SingSharp.Reflection;
  15. using Microsoft.Singularity.Applications;
  16. using Microsoft.Singularity.Io;
  17. using Microsoft.Singularity.Configuration;
  18. [assembly: Transform(typeof(ApplicationResourceTransform))]
  19. namespace Microsoft.Singularity.Applications
  20. {
  21. [ConsoleCategory(DefaultAction=true)]
  22. internal class Parameters {
  23. [InputEndpoint("data")]
  24. public readonly TRef<UnicodePipeContract.Exp:READY> Stdin;
  25. [OutputEndpoint("data")]
  26. public readonly TRef<UnicodePipeContract.Imp:READY> Stdout;
  27. reflective internal Parameters();
  28. internal int AppMain() {
  29. return ThrowWithLinkStack.AppMain(this);
  30. }
  31. }
  32. public class ThrowWithLinkStack
  33. {
  34. //[ShellCommand("throwWithLinkStack", "Throw an exception with link stack")]
  35. internal static int AppMain(Parameters! config)
  36. {
  37. try {
  38. DebugStub.Print("About to throw exception\n");
  39. Throw();
  40. }
  41. catch (Exception e) {
  42. Console.WriteLine("Throw with Link Stack Caught exception {0}", e);
  43. }
  44. return 0;
  45. }
  46. [RequireStackLink]
  47. public static int Throw() {
  48. throw new ApplicationException("AppException");
  49. }
  50. }
  51. }