Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial batch of nominal types for DiagnosticSource events #8351

Merged
merged 1 commit into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/EFCore.InMemory/Storage/Internal/InMemoryTransaction.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace Microsoft.EntityFrameworkCore.Storage.Internal
{
public class InMemoryTransaction : IDbContextTransaction
{
public virtual Guid TransactionId { get; } = Guid.NewGuid();

public virtual void Commit()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private enum Id
public static readonly EventId ForeignKeyColumnMissingWarning = MakeScaffoldingId(Id.ForeignKeyColumnMissingWarning);

/// <summary>
/// A foreign key column was not found.
/// A column referenced by a foreign key constraint was not found.
/// This event is in the <see cref="LoggerCategory.Scaffolding" /> category.
/// </summary>
public static readonly EventId ForeignKeyPrincipalColumnMissingWarning = MakeScaffoldingId(Id.ForeignKeyPrincipalColumnMissingWarning);
Expand All @@ -188,7 +188,7 @@ private enum Id
public static readonly EventId IndexNotNamedWarning = MakeScaffoldingId(Id.IndexNotNamedWarning);

/// <summary>
/// The table references by an index was not found.
/// The table referened by an index was not found.
/// This event is in the <see cref="LoggerCategory.Scaffolding" /> category.
/// </summary>
public static readonly EventId IndexTableMissingWarning = MakeScaffoldingId(Id.IndexTableMissingWarning);
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Relational.Design/Metadata/SequenceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public class SequenceModel : Annotatable
public virtual bool? IsCyclic { get; [param: CanBeNull] set; }

public virtual string DisplayName
=> (!string.IsNullOrEmpty(SchemaName) ? SchemaName + "." : "") + Name;
=> !string.IsNullOrEmpty(SchemaName) ? (SchemaName + "." + Name) : Name;
}
}
2 changes: 1 addition & 1 deletion src/EFCore.Relational.Design/Metadata/TableModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public class TableModel : Annotatable
public virtual ICollection<ForeignKeyModel> ForeignKeys { get; } = new List<ForeignKeyModel>();

public virtual string DisplayName
=> (!string.IsNullOrEmpty(SchemaName) ? SchemaName + "." : "") + Name;
=> !string.IsNullOrEmpty(SchemaName) ? (SchemaName + "." + Name) : Name;
}
}
85 changes: 85 additions & 0 deletions src/EFCore.Relational/Diagnostics/CommandData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Data.Common;
using System.Diagnostics;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Diagnostics
{
/// <summary>
/// The <see cref="DiagnosticSource" /> event payload for
/// <see cref="RelationalEventId" /> command events.
/// </summary>
public class CommandData
{
/// <summary>
/// Constructs the event payload.
/// </summary>
/// <param name="command">
/// The <see cref="DbCommand" />.
/// </param>
/// <param name="executeMethod">
/// The <see cref="DbCommand" /> method.
/// </param>
/// <param name="commandId">
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used.
/// </param>
/// <param name="connectionId">
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used.
/// </param>
/// <param name="async">
/// Indicates whether or not the command was executed asyncronously.
/// </param>
/// <param name="timestamp">
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing.
/// </param>
public CommandData(
[NotNull] DbCommand command,
DbCommandMethod executeMethod,
Guid commandId,
Guid connectionId,
bool async,
long timestamp)
{
Command = command;
CommandId = commandId;
ConnectionId = connectionId;
ExecuteMethod = executeMethod;
Async = async;
Timestamp = timestamp;
}

/// <summary>
/// The <see cref="DbCommand" />.
/// </summary>
public virtual DbCommand Command { get; }

/// <summary>
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used.
/// </summary>
public virtual Guid CommandId { get; }

/// <summary>
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used.
/// </summary>
public virtual Guid ConnectionId { get; }

/// <summary>
/// The <see cref="DbCommand" /> method.
/// </summary>
public virtual DbCommandMethod ExecuteMethod { get; }

/// <summary>
/// Indicates whether or not the operation is being executed asyncronously.
/// </summary>
public virtual bool Async { get; }

/// <summary>
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing.
/// </summary>
public virtual long Timestamp { get; }
}
}
60 changes: 60 additions & 0 deletions src/EFCore.Relational/Diagnostics/CommandEndData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Data.Common;
using System.Diagnostics;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Diagnostics
{
/// <summary>
/// The <see cref="DiagnosticSource" /> event payload for
/// <see cref="RelationalEventId" /> command end events.
/// </summary>
public class CommandEndData : CommandData
{
/// <summary>
/// Constructs the event payload.
/// </summary>
/// <param name="command">
/// The <see cref="DbCommand" />.
/// </param>
/// <param name="executeMethod">
/// The <see cref="DbCommand" /> method.
/// </param>
/// <param name="commandId">
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used.
/// </param>
/// <param name="connectionId">
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used.
/// </param>
/// <param name="async">
/// Indicates whether or not the command was executed asyncronously.
/// </param>
/// <param name="timestamp">
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing.
/// </param>
/// <param name="duration">
/// The duration of execution as ticks from <see cref="Stopwatch.GetTimestamp" />.
/// </param>
public CommandEndData(
[NotNull] DbCommand command,
DbCommandMethod executeMethod,
Guid commandId,
Guid connectionId,
bool async,
long timestamp,
long duration)
: base(command, executeMethod, commandId, connectionId, async, timestamp)
{
Duration = duration;
}

/// <summary>
/// The duration of execution as ticks from <see cref="Stopwatch.GetTimestamp" />.
/// </summary>
public virtual long Duration { get; }
}
}
64 changes: 64 additions & 0 deletions src/EFCore.Relational/Diagnostics/CommandErrorData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Data.Common;
using System.Diagnostics;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Diagnostics
{
/// <summary>
/// The <see cref="DiagnosticSource" /> event payload for <see cref="RelationalEventId.CommandError" />.
/// </summary>
public class CommandErrorData : CommandEndData
{
/// <summary>
/// Constructs the event payload.
/// </summary>
/// <param name="command">
/// The <see cref="DbCommand" /> that was executing when it failed.
/// </param>
/// <param name="executeMethod">
/// The <see cref="DbCommand" /> method that was used to execute the command.
/// </param>
/// <param name="commandId">
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used.
/// </param>
/// <param name="connectionId">
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used.
/// </param>
/// <param name="exception">
/// The exception that was thrown when execution failed.
/// </param>
/// <param name="async">
/// Indicates whether or not the command was executed asyncronously.
/// </param>
/// <param name="timestamp">
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used
/// with <see cref="RelationalEventId.CommandExecuting" /> to time execution.
/// </param>
/// <param name="duration">
/// The duration of execution as ticks from <see cref="Stopwatch.GetTimestamp" />.
/// </param>
public CommandErrorData(
[NotNull] DbCommand command,
DbCommandMethod executeMethod,
Guid commandId,
Guid connectionId,
[NotNull] Exception exception,
bool async,
long timestamp,
long duration)
: base(command, executeMethod, commandId, connectionId, async, timestamp, duration)
{
Exception = exception;
}

/// <summary>
/// The exception that was thrown when execution failed.
/// </summary>
public virtual Exception Exception { get; }
}
}
64 changes: 64 additions & 0 deletions src/EFCore.Relational/Diagnostics/CommandExecutedData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Data.Common;
using System.Diagnostics;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Diagnostics
{
/// <summary>
/// The <see cref="DiagnosticSource" /> event payload for <see cref="RelationalEventId.CommandExecuted" />.
/// </summary>
public class CommandExecutedData : CommandEndData
{
/// <summary>
/// Constructs the event payload.
/// </summary>
/// <param name="command">
/// The <see cref="DbCommand" /> that was executing when it failed.
/// </param>
/// <param name="executeMethod">
/// The <see cref="DbCommand" /> method that was used to execute the command.
/// </param>
/// <param name="commandId">
/// A correlation ID that identifies the <see cref="DbCommand" /> instance being used.
/// </param>
/// <param name="connectionId">
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used.
/// </param>
/// <param name="result">
/// The result of executing the operation.
/// </param>
/// <param name="async">
/// Indicates whether or not the command was executed asyncronously.
/// </param>
/// <param name="timestamp">
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used
/// with <see cref="RelationalEventId.CommandExecuting" /> to time execution.
/// </param>
/// <param name="duration">
/// The duration of execution as ticks from <see cref="Stopwatch.GetTimestamp" />.
/// </param>
public CommandExecutedData(
[NotNull] DbCommand command,
DbCommandMethod executeMethod,
Guid commandId,
Guid connectionId,
[CanBeNull] object result,
bool async,
long timestamp,
long duration)
: base(command, executeMethod, commandId, connectionId, async, timestamp, duration)
{
Result = result;
}

/// <summary>
/// The result of executing the command.
/// </summary>
public virtual object Result { get; }
}
}
65 changes: 65 additions & 0 deletions src/EFCore.Relational/Diagnostics/ConnectionData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Data.Common;
using System.Diagnostics;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace Microsoft.EntityFrameworkCore.Diagnostics
{
/// <summary>
/// The <see cref="DiagnosticSource" /> event payload base class for
/// <see cref="RelationalEventId" /> connection events.
/// </summary>
public class ConnectionData
{
/// <summary>
/// Constructs the event payload.
/// </summary>
/// <param name="connection">
/// The <see cref="DbConnection" />.
/// </param>
/// <param name="connectionId">
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used.
/// </param>
/// <param name="async">
/// Indicates whether or not the operation is happening asyncronously.
/// </param>
/// <param name="timestamp">
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing.
/// </param>
public ConnectionData(
[NotNull] DbConnection connection,
Guid connectionId,
bool async,
long timestamp)
{
Connection = connection;
ConnectionId = connectionId;
Async = async;
Timestamp = timestamp;
}

/// <summary>
/// The <see cref="DbConnection" />.
/// </summary>
public virtual DbConnection Connection { get; }

/// <summary>
/// A correlation ID that identifies the <see cref="DbConnection" /> instance being used.
/// </summary>
public virtual Guid ConnectionId { get; }

/// <summary>
/// Indicates whether or not the operation is happening asyncronously.
/// </summary>
public virtual bool Async { get; }

/// <summary>
/// A timestamp from <see cref="Stopwatch.GetTimestamp" /> that can be used for timing.
/// </summary>
public virtual long Timestamp { get; }
}
}
Loading