Exemplo n.º 1
0
        public virtual void Dispose()
        {
            // Disposing the json writer closes the stream but the textwriter
            // still needs to be disposed or closed to write the results
            if (_issueLogJsonWriter != null)
            {
                _issueLogJsonWriter.CloseResults();

                if (_run?.Invocations?.Count > 0 && _run.Invocations[0].StartTime != new DateTime())
                {
                    _run.Invocations[0].EndTime = DateTime.UtcNow;
                }

                // Note: we write out the backing rules
                // to prevent the property accessor from populating
                // this data with an empty collection.
                if (_rules != null)
                {
                    _issueLogJsonWriter.WriteRules(_rules);
                }

                if (_run?.Files != null)
                {
                    _issueLogJsonWriter.WriteFiles(_run.Files);
                }

                if (_run?.Invocations != null)
                {
                    _issueLogJsonWriter.WriteInvocations(invocations: _run.Invocations);
                }

                if (_run?.Properties != null)
                {
                    _issueLogJsonWriter.WriteRunProperties(_run.Properties);
                }

                _issueLogJsonWriter.Dispose();
            }

            if (_textWriter != null)
            {
                _textWriter.Dispose();
            }

            if (_jsonTextWriter == null)
            {
                _jsonTextWriter.Close();
            }

            GC.SuppressFinalize(this);
        }
Exemplo n.º 2
0
        public virtual void Dispose()
        {
            // Disposing the json writer closes the stream but the textwriter
            // still needs to be disposed or closed to write the results
            if (_issueLogJsonWriter != null)
            {
                _issueLogJsonWriter.CloseResults();

                if (_run?.Invocations?.Count > 0 && _run.Invocations[0].StartTimeUtc != new DateTime())
                {
                    _run.Invocations[0].EndTimeUtc = DateTime.UtcNow;
                }

                if (_run?.Tool != null)
                {
                    _issueLogJsonWriter.WriteTool(_run.Tool);
                }

                if (_run?.Artifacts != null)
                {
                    _issueLogJsonWriter.WriteArtifacts(_run.Artifacts);
                }

                if (_run?.Invocations != null)
                {
                    _issueLogJsonWriter.WriteInvocations(invocations: _run.Invocations);
                }

                if (_run?.Properties != null)
                {
                    _issueLogJsonWriter.WriteRunProperties(_run.Properties);
                }

                _issueLogJsonWriter.Dispose();
            }

            if (_textWriter != null)
            {
                _textWriter.Dispose();
            }

            if (_jsonTextWriter == null)
            {
                _jsonTextWriter.Close();
            }

            GC.SuppressFinalize(this);
        }