Beispiel #1
0
        /// <summary>
        /// Writes down the C# instruction.
        /// </summary>
        /// <param name="writer">The stream on which to write.</param>
        public override void WriteCSharp(ICSharpWriter writer)
        {
            Debug.Assert(WriteDown);

            ICSharpExpressionContext SourceExpressionContext = new CSharpExpressionContext();

            BooleanExpression.WriteCSharp(writer, SourceExpressionContext, -1);

            string ExpressionText = SourceExpressionContext.ReturnValue;

            if (BooleanExpression.IsEventExpression)
            {
                if (BooleanExpression.IsComplex)
                {
                    ExpressionText = $"({ExpressionText}).IsSignaled";
                }
                else
                {
                    ExpressionText += ".IsSignaled";
                }
            }

            writer.WriteIndentedLine($"Debug.Assert({ExpressionText});");
            writer.AddUsing("System.Diagnostics");
        }
Beispiel #2
0
        /// <summary>
        /// Writes down the C# assertion.
        /// </summary>
        /// <param name="writer">The stream on which to write.</param>
        public virtual void WriteCSharp(ICSharpWriter writer)
        {
            Debug.Assert(WriteDown);

            ICSharpExpressionContext SourceExpressionContext = new CSharpExpressionContext();

            BooleanExpression.WriteCSharp(writer, SourceExpressionContext, -1);

            string AssertionString = SourceExpressionContext.ReturnValue;

            Debug.Assert(AssertionString != null);

            string TagString = string.IsNullOrEmpty(Tag) ? string.Empty : $" // {Tag}";

            writer.WriteIndentedLine($"Debug.Assert({AssertionString});{TagString}");

            writer.AddUsing("System.Diagnostics");
        }