Skip to content

Commit 30a3f1e

Browse files
committed
Revert "Remove Diagnostics out of netstandard2.0"
This reverts commit 6a31191.
1 parent 6a31191 commit 30a3f1e

28 files changed

Lines changed: 22 additions & 166 deletions

ServiceStack.Aws/src/ServiceStack.Aws/Sqs/SqsMqMessageProducer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ public void Publish<T>(T messageBody)
3131
{
3232
if (messageBody is IMessage message)
3333
{
34-
#if NET472 || NET6_0_OR_GREATER
3534
Diagnostics.ServiceStack.Init(message);
36-
#endif
3735
Publish(message.ToInQueueName(), message);
3836
}
3937
else

ServiceStack.Azure/src/ServiceStack.Azure/Messaging/ServiceBusMqMessageProducer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ public void Publish<T>(T messageBody)
4242
// Ensure we're publishing an IMessage
4343
if (messageBody is IMessage message)
4444
{
45-
#if NET472 || NET6_0_OR_GREATER
4645
Diagnostics.ServiceStack.Init(message);
47-
#endif
4846
Publish(message.ToInQueueName(), message);
4947
}
5048
else

ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteConnection.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public IDbTransaction BeginTransaction(IsolationLevel isolationLevel)
5959

6060
public void Close()
6161
{
62-
#if NET472 || NET6_0_OR_GREATER
6362
var id = Diagnostics.OrmLite.WriteConnectionCloseBefore(DbConnection);
64-
#endif
6563
var connectionId = DbConnection.GetConnectionId();
6664
Exception e = null;
6765
try
@@ -75,12 +73,10 @@ public void Close()
7573
}
7674
finally
7775
{
78-
#if NET472 || NET6_0_OR_GREATER
7976
if (e != null)
8077
Diagnostics.OrmLite.WriteConnectionCloseError(id, connectionId, DbConnection, e);
8178
else
8279
Diagnostics.OrmLite.WriteConnectionCloseAfter(id, connectionId, DbConnection);
83-
#endif
8480
}
8581
}
8682

@@ -106,9 +102,7 @@ public void Open()
106102

107103
if (DbConnection.State == ConnectionState.Closed)
108104
{
109-
#if NET472 || NET6_0_OR_GREATER
110105
var id = Diagnostics.OrmLite.WriteConnectionOpenBefore(DbConnection);
111-
#endif
112106
Exception e = null;
113107
try
114108
{
@@ -126,12 +120,10 @@ public void Open()
126120
}
127121
finally
128122
{
129-
#if NET472 || NET6_0_OR_GREATER
130123
if (e != null)
131124
Diagnostics.OrmLite.WriteConnectionOpenError(id, DbConnection, e);
132125
else
133126
Diagnostics.OrmLite.WriteConnectionOpenAfter(id, DbConnection);
134-
#endif
135127
}
136128
}
137129
}
@@ -143,9 +135,7 @@ public async Task OpenAsync(CancellationToken token = default)
143135

144136
if (DbConnection.State == ConnectionState.Closed)
145137
{
146-
#if NET472 || NET6_0_OR_GREATER
147138
var id = Diagnostics.OrmLite.WriteConnectionOpenBefore(DbConnection);
148-
#endif
149139
Exception e = null;
150140
try
151141
{
@@ -163,12 +153,10 @@ public async Task OpenAsync(CancellationToken token = default)
163153
}
164154
finally
165155
{
166-
#if NET472 || NET6_0_OR_GREATER
167156
if (e != null)
168157
Diagnostics.OrmLite.WriteConnectionOpenError(id, DbConnection, e);
169158
else
170159
Diagnostics.OrmLite.WriteConnectionOpenAfter(id, DbConnection);
171-
#endif
172160
}
173161
}
174162
}

ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteDiagnostics.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET472 || NET6_0_OR_GREATER
21
using System;
32
using System.Data;
43
using System.Diagnostics;
@@ -281,4 +280,4 @@ public static void WriteTransactionRollbackError(this DiagnosticListener listene
281280
}
282281

283282
}
284-
#endif
283+

ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteExecFilter.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public virtual void DisposeCommand(IDbCommand dbCmd, IDbConnection dbConn)
5959
public virtual T Exec<T>(IDbConnection dbConn, Func<IDbCommand, T> filter)
6060
{
6161
var dbCmd = CreateCommand(dbConn);
62-
#if NET472 || NET6_0_OR_GREATER
6362
var id = Diagnostics.OrmLite.WriteCommandBefore(dbCmd);
64-
#endif
6563
Exception e = null;
6664
try
6765
{
@@ -76,12 +74,10 @@ public virtual T Exec<T>(IDbConnection dbConn, Func<IDbCommand, T> filter)
7674
}
7775
finally
7876
{
79-
#if NET472 || NET6_0_OR_GREATER
8077
if (e != null)
8178
Diagnostics.OrmLite.WriteCommandError(id, dbCmd, e);
8279
else
8380
Diagnostics.OrmLite.WriteCommandAfter(id, dbCmd);
84-
#endif
8581
DisposeCommand(dbCmd, dbConn);
8682
}
8783
}
@@ -100,9 +96,7 @@ public virtual IDbCommand Exec(IDbConnection dbConn, Func<IDbCommand, IDbCommand
10096
public virtual void Exec(IDbConnection dbConn, Action<IDbCommand> filter)
10197
{
10298
var dbCmd = CreateCommand(dbConn);
103-
#if NET472 || NET6_0_OR_GREATER
10499
var id = Diagnostics.OrmLite.WriteCommandBefore(dbCmd);
105-
#endif
106100
Exception e = null;
107101
try
108102
{
@@ -116,22 +110,18 @@ public virtual void Exec(IDbConnection dbConn, Action<IDbCommand> filter)
116110
}
117111
finally
118112
{
119-
#if NET472 || NET6_0_OR_GREATER
120113
if (e != null)
121114
Diagnostics.OrmLite.WriteCommandError(id, dbCmd, e);
122115
else
123116
Diagnostics.OrmLite.WriteCommandAfter(id, dbCmd);
124-
#endif
125117
DisposeCommand(dbCmd, dbConn);
126118
}
127119
}
128120

129121
public virtual async Task<T> Exec<T>(IDbConnection dbConn, Func<IDbCommand, Task<T>> filter)
130122
{
131123
var dbCmd = CreateCommand(dbConn);
132-
#if NET472 || NET6_0_OR_GREATER
133124
var id = Diagnostics.OrmLite.WriteCommandBefore(dbCmd);
134-
#endif
135125
Exception e = null;
136126

137127
try
@@ -146,12 +136,10 @@ public virtual async Task<T> Exec<T>(IDbConnection dbConn, Func<IDbCommand, Task
146136
}
147137
finally
148138
{
149-
#if NET472 || NET6_0_OR_GREATER
150139
if (e != null)
151140
Diagnostics.OrmLite.WriteCommandError(id, dbCmd, e);
152141
else
153142
Diagnostics.OrmLite.WriteCommandAfter(id, dbCmd);
154-
#endif
155143
DisposeCommand(dbCmd, dbConn);
156144
}
157145
}
@@ -165,9 +153,7 @@ public virtual async Task<IDbCommand> Exec(IDbConnection dbConn, Func<IDbCommand
165153
public virtual async Task Exec(IDbConnection dbConn, Func<IDbCommand, Task> filter)
166154
{
167155
var dbCmd = CreateCommand(dbConn);
168-
#if NET472 || NET6_0_OR_GREATER
169156
var id = Diagnostics.OrmLite.WriteCommandBefore(dbCmd);
170-
#endif
171157
Exception e = null;
172158

173159
try
@@ -182,22 +168,18 @@ public virtual async Task Exec(IDbConnection dbConn, Func<IDbCommand, Task> filt
182168
}
183169
finally
184170
{
185-
#if NET472 || NET6_0_OR_GREATER
186171
if (e != null)
187172
Diagnostics.OrmLite.WriteCommandError(id, dbCmd, e);
188173
else
189174
Diagnostics.OrmLite.WriteCommandAfter(id, dbCmd);
190-
#endif
191175
DisposeCommand(dbCmd, dbConn);
192176
}
193177
}
194178

195179
public virtual IEnumerable<T> ExecLazy<T>(IDbConnection dbConn, Func<IDbCommand, IEnumerable<T>> filter)
196180
{
197181
var dbCmd = CreateCommand(dbConn);
198-
#if NET472 || NET6_0_OR_GREATER
199182
var id = Diagnostics.OrmLite.WriteCommandBefore(dbCmd);
200-
#endif
201183
try
202184
{
203185
var results = filter(dbCmd);
@@ -208,9 +190,7 @@ public virtual IEnumerable<T> ExecLazy<T>(IDbConnection dbConn, Func<IDbCommand,
208190
}
209191
finally
210192
{
211-
#if NET472 || NET6_0_OR_GREATER
212193
Diagnostics.OrmLite.WriteCommandAfter(id, dbCmd);
213-
#endif
214194
DisposeCommand(dbCmd, dbConn);
215195
}
216196
}

ServiceStack.OrmLite/src/ServiceStack.OrmLite/OrmLiteTransaction.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ public static OrmLiteTransaction Create(IDbConnection db, IsolationLevel? isolat
1717
? db.BeginTransaction(isolationLevel.Value)
1818
: db.BeginTransaction();
1919

20-
#if NET472 || NET6_0_OR_GREATER
2120
Diagnostics.OrmLite.WriteTransactionOpen(dbTrans.IsolationLevel, db);
22-
#endif
2321
var trans = new OrmLiteTransaction(db, dbTrans);
2422

2523
return trans;
@@ -63,9 +61,7 @@ public void Dispose()
6361
public void Commit()
6462
{
6563
var isolationLevel = Transaction.IsolationLevel;
66-
#if NET472 || NET6_0_OR_GREATER
6764
var id = Diagnostics.OrmLite.WriteTransactionCommitBefore(isolationLevel, db);
68-
#endif
6965
Exception e = null;
7066
try
7167
{
@@ -78,21 +74,17 @@ public void Commit()
7874
}
7975
finally
8076
{
81-
#if NET472 || NET6_0_OR_GREATER
8277
if (e != null)
8378
Diagnostics.OrmLite.WriteTransactionCommitError(id, isolationLevel, db, e);
8479
else
8580
Diagnostics.OrmLite.WriteTransactionCommitAfter(id, isolationLevel, db);
86-
#endif
8781
}
8882
}
8983

9084
public void Rollback()
9185
{
9286
var isolationLevel = Transaction.IsolationLevel;
93-
#if NET472 || NET6_0_OR_GREATER
9487
var id = Diagnostics.OrmLite.WriteTransactionRollbackBefore(isolationLevel, db, null);
95-
#endif
9688
Exception e = null;
9789
try
9890
{
@@ -105,17 +97,15 @@ public void Rollback()
10597
}
10698
finally
10799
{
108-
#if NET472 || NET6_0_OR_GREATER
109100
if (e != null)
110101
Diagnostics.OrmLite.WriteTransactionRollbackError(id, isolationLevel, db, null, e);
111102
else
112103
Diagnostics.OrmLite.WriteTransactionRollbackAfter(id, isolationLevel, db, null);
113-
#endif
114104
}
115105
}
116106

117107
public IDbConnection Connection => Transaction.Connection;
118108

119109
public IsolationLevel IsolationLevel => Transaction.IsolationLevel;
120110
}
121-
}
111+
}

ServiceStack.Redis/src/ServiceStack.Redis/RedisDiagnostics.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if NET472 || NET6_0_OR_GREATER
21
using System;
32
using System.Diagnostics;
43
using System.Runtime.CompilerServices;
@@ -214,5 +213,4 @@ public static void WritePoolReturn(this DiagnosticListener listener, Guid operat
214213
}.Init(Activity.Current));
215214
}
216215
}
217-
}
218-
#endif
216+
}

ServiceStack.Redis/src/ServiceStack.Redis/RedisNativeClient.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,9 +2501,8 @@ private void SafeConnectionClose()
25012501

25022502
try
25032503
{
2504-
#if NET472 || NET6_0_OR_GREATER
25052504
id = Diagnostics.Redis.WriteConnectionCloseBefore(this);
2506-
#endif
2505+
25072506
// workaround for a .net bug: http://support.microsoft.com/kb/821625
25082507
bufferedReader?.Close();
25092508
}
@@ -2523,12 +2522,10 @@ private void SafeConnectionClose()
25232522
sslStream = null;
25242523
socket = null;
25252524

2526-
#if NET472 || NET6_0_OR_GREATER
25272525
if (e != null)
25282526
Diagnostics.Redis.WriteConnectionCloseError(id, this, e);
25292527
else
25302528
Diagnostics.Redis.WriteConnectionCloseAfter(id, this);
2531-
#endif
25322529
}
25332530
}
25342531
}

ServiceStack.Redis/src/ServiceStack.Redis/RedisNativeClient_Utils.Async.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ private async ValueTask<T> SendReceiveAsync<T>(byte[][] cmdWithBinaryArgs,
190190

191191
if (!didWriteToBuffer) //only write to buffer once
192192
{
193-
#if NET472 || NET6_0_OR_GREATER
194193
id = Diagnostics.Redis.WriteCommandBefore(cmdWithBinaryArgs, operation);
195-
#endif
196194
WriteCommandToSendBuffer(cmdWithBinaryArgs);
197195
didWriteToBuffer = true;
198196
}
@@ -213,9 +211,7 @@ private async ValueTask<T> SendReceiveAsync<T>(byte[][] cmdWithBinaryArgs,
213211
if (i > 0)
214212
{
215213
Interlocked.Increment(ref RedisState.TotalRetrySuccess);
216-
#if NET472 || NET6_0_OR_GREATER
217214
Diagnostics.Redis.WriteCommandRetry(id, cmdWithBinaryArgs, operation);
218-
#endif
219215
}
220216

221217
var result = default(T);
@@ -266,13 +262,10 @@ private async ValueTask<T> SendReceiveAsync<T>(byte[][] cmdWithBinaryArgs,
266262
}
267263
finally
268264
{
269-
#if NET472 || NET6_0_OR_GREATER
270-
271265
if (wasError != null)
272266
Diagnostics.Redis.WriteCommandError(id, cmdWithBinaryArgs, originalEx ?? wasError, operation);
273267
else
274268
Diagnostics.Redis.WriteCommandAfter(id, cmdWithBinaryArgs, operation);
275-
#endif
276269
}
277270
}
278271
}

0 commit comments

Comments
 (0)