Skip to content

Commit c5492f3

Browse files
author
Tsar Nikolay
committed
Implemented proper support of netstandard2.0
1 parent 8178e51 commit c5492f3

File tree

89 files changed

+419
-29602
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+419
-29602
lines changed

log4net.nuspec

Lines changed: 0 additions & 127 deletions
This file was deleted.

src/log4net.Tests/Appender/AdoNetAppenderTest.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@
2121

2222
using System;
2323
using System.Data;
24+
#if NETSTANDARD1_3
25+
using System.Reflection;
26+
#endif
2427
using System.Xml;
2528
using log4net.Appender;
2629
using log4net.Config;
30+
#if !NETSTANDARD1_3
2731
using log4net.Core;
32+
#endif
2833
using log4net.Layout;
2934
using log4net.Repository;
3035
using log4net.Tests.Appender.AdoNet;
@@ -43,13 +48,18 @@ public void NoBufferingTest()
4348

4449
AdoNetAppender adoNetAppender = new AdoNetAppender();
4550
adoNetAppender.BufferSize = -1;
51+
#if NETSTANDARD1_3
52+
adoNetAppender.ConnectionType = typeof(Log4NetConnection).AssemblyQualifiedName;
53+
#else
4654
adoNetAppender.ConnectionType = "log4net.Tests.Appender.AdoNet.Log4NetConnection";
55+
#endif
4756
adoNetAppender.ActivateOptions();
4857

4958
BasicConfigurator.Configure(rep, adoNetAppender);
5059

5160
ILog log = LogManager.GetLogger(rep.Name, "NoBufferingTest");
5261
log.Debug("Message");
62+
Assert.NotNull(Log4NetCommand.MostRecentInstance);
5363
Assert.AreEqual(1, Log4NetCommand.MostRecentInstance.ExecuteNonQueryCount);
5464
}
5565

@@ -62,7 +72,11 @@ public void BufferingTest()
6272

6373
AdoNetAppender adoNetAppender = new AdoNetAppender();
6474
adoNetAppender.BufferSize = bufferSize;
75+
#if NETSTANDARD1_3
76+
adoNetAppender.ConnectionType = typeof(Log4NetConnection).AssemblyQualifiedName;
77+
#else
6578
adoNetAppender.ConnectionType = "log4net.Tests.Appender.AdoNet.Log4NetConnection";
79+
#endif
6680
adoNetAppender.ActivateOptions();
6781

6882
BasicConfigurator.Configure(rep, adoNetAppender);
@@ -74,9 +88,11 @@ public void BufferingTest()
7488
Assert.IsNull(Log4NetCommand.MostRecentInstance);
7589
}
7690
log.Debug("Message");
91+
Assert.NotNull(Log4NetCommand.MostRecentInstance);
7792
Assert.AreEqual(bufferSize+1, Log4NetCommand.MostRecentInstance.ExecuteNonQueryCount);
7893
}
7994

95+
#if !NETSTANDARD1_3
8096
[Test]
8197
public void WebsiteExample()
8298
{
@@ -147,6 +163,7 @@ public void WebsiteExample()
147163

148164
IDbCommand command = Log4NetCommand.MostRecentInstance;
149165

166+
Assert.NotNull(command);
150167
Assert.AreEqual(
151168
"INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)",
152169
command.CommandText);
@@ -240,6 +257,7 @@ public void BufferingWebsiteExample()
240257

241258
IDbCommand command = Log4NetCommand.MostRecentInstance;
242259

260+
Assert.NotNull(command);
243261
Assert.AreEqual(
244262
"INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)",
245263
command.CommandText);
@@ -258,6 +276,7 @@ public void BufferingWebsiteExample()
258276
param = (IDbDataParameter)command.Parameters["@exception"];
259277
Assert.IsEmpty((string)param.Value);
260278
}
279+
#endif
261280

262281
[Test]
263282
public void NullPropertyXmlConfig()
@@ -293,6 +312,8 @@ public void NullPropertyXmlConfig()
293312

294313
log.Debug("Message");
295314
IDbCommand command = Log4NetCommand.MostRecentInstance;
315+
Assert.NotNull(command);
316+
296317
IDbDataParameter param = (IDbDataParameter)command.Parameters["@productId"];
297318
Assert.AreNotEqual(SystemInfo.NullText, param.Value);
298319
Assert.AreEqual(DBNull.Value, param.Value);
@@ -310,7 +331,11 @@ public void NullPropertyProgmaticConfig()
310331
productIdParam.Layout = rawPropertyLayout;
311332

312333
AdoNetAppender appender = new AdoNetAppender();
334+
#if NETSTANDARD1_3
335+
appender.ConnectionType = typeof(Log4NetConnection).AssemblyQualifiedName;
336+
#else
313337
appender.ConnectionType = typeof(Log4NetConnection).FullName;
338+
#endif
314339
appender.BufferSize = -1;
315340
appender.CommandText = "INSERT INTO Log ([productId]) VALUES (@productId)";
316341
appender.AddParameter(productIdParam);
@@ -322,6 +347,8 @@ public void NullPropertyProgmaticConfig()
322347

323348
log.Debug("Message");
324349
IDbCommand command = Log4NetCommand.MostRecentInstance;
350+
Assert.NotNull(command);
351+
325352
IDbDataParameter param = (IDbDataParameter)command.Parameters["@productId"];
326353
Assert.AreNotEqual(SystemInfo.NullText, param.Value);
327354
Assert.AreEqual(DBNull.Value, param.Value);

src/log4net.Tests/Appender/DebugAppenderTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*
1919
*/
2020

21+
#if NET_2_0
22+
2123
using System;
2224
using System.Diagnostics;
2325
using log4net.Appender;
@@ -113,7 +115,6 @@ public void DefaultCategoryTest()
113115
Debug.Listeners.Remove(categoryTraceListener);
114116
}
115117

116-
#if !NETSTANDARD1_3 // "LocationInfo can't get method names on NETSTANDARD1_3 due to unavailable stack frame APIs"
117118
[Test]
118119
public void MethodNameCategoryTest()
119120
{
@@ -140,7 +141,6 @@ public void MethodNameCategoryTest()
140141

141142
Debug.Listeners.Remove(categoryTraceListener);
142143
}
143-
#endif
144144

145145
private class TestErrorHandler : IErrorHandler
146146
{
@@ -171,3 +171,5 @@ public void Error(string message)
171171
}
172172
}
173173
}
174+
175+
#endif

src/log4net.Tests/Appender/EventLogAppenderTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
//
1818
#endregion
1919

20+
// netstandard doesn't support EventLog
21+
#if NET_2_0
22+
2023
using System.Diagnostics;
2124

2225
using log4net.Appender;
@@ -98,3 +101,5 @@ private static EventLogEntryType GetEntryType(EventLogAppender appender, Level l
98101

99102
}
100103
}
104+
105+
#endif // NET_2_0

src/log4net.Tests/Appender/EventRaisingAppender.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
*/
2121

2222
#if !NET_2_0 && !MONO_2_0
23+
2324
using System;
24-
using System.Collections.Generic;
25-
using System.Linq;
26-
using System.Text;
27-
using System.Threading.Tasks;
2825

2926
namespace log4net.Tests.Appender
3027
{

src/log4net.Tests/Appender/MemoryAppenderTest.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@
1919
*
2020
*/
2121

22-
#if NET_4_0 || MONO_3_5 || MONO_4_0
22+
#if NET_4_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD
2323

2424
using System;
2525
using System.Linq;
2626
using System.Threading;
2727
using NUnit.Framework;
28-
using log4net;
2928
using log4net.Appender;
3029
using log4net.Config;
31-
using log4net.Core;
3230
using log4net.Layout;
3331
using log4net.Repository;
3432

src/log4net.Tests/Appender/RecursiveLoggingTest.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,10 @@
2121

2222
#if !NET_2_0 && !MONO_2_0
2323
using System;
24-
using System.Data;
25-
using System.Xml;
26-
using log4net.Appender;
24+
using System.Globalization;
2725
using log4net.Config;
2826
using log4net.Core;
29-
using log4net.Layout;
30-
using log4net.Repository;
31-
using log4net.Util;
3227
using NUnit.Framework;
33-
using System.Globalization;
3428

3529
namespace log4net.Tests.Appender
3630
{

src/log4net.Tests/Appender/RemotingAppenderTest.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
//
1818
#endregion
1919

20+
// .NET Compact Framework 1.0 && netstandard has no support for System.Runtime.Remoting
21+
#if NET_2_0
22+
2023
using System;
2124
using System.Collections;
2225
using System.Reflection;
@@ -283,7 +286,7 @@ public void TearDown()
283286
/// <summary>
284287
/// Close down remoting infrastructure
285288
/// </summary>
286-
[TestFixtureTearDown]
289+
[OneTimeTearDown]
287290
public void UnregisterRemotingServerChannel() {
288291
if (m_remotingChannel != null) {
289292
((TcpChannel) m_remotingChannel).StopListening(null);
@@ -448,4 +451,6 @@ public void Test()
448451
}
449452
}
450453
}
451-
}
454+
}
455+
456+
#endif // NET_2_0

0 commit comments

Comments
 (0)