Skip to content

Commit c728a70

Browse files
authored
Merge pull request #63 from Flexberry/netstd20-support
2 parents 9b8d1a4 + 9f2de30 commit c728a70

File tree

97 files changed

+463
-29616
lines changed

Some content is hidden

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

97 files changed

+463
-29616
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,4 @@ build-tools
242242
buildreports
243243
vs_buildtools.exe
244244
dotnetfx35.exe
245+
*.exe

BUILDING.md

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ Options:
1818
- on Win10+, this can only be installed via Add/Remove Windows Components
1919
- on other platforms, see https://dotnet.microsoft.com/download/dotnet-framework/net35-sp1
2020
- Building against .net 2/3.5, especially Client Profile, is not supported on Mono
21+
- Log4Net supports some older, out-of-support .net SDKs, particularly
22+
dotnet core 1.1 and .net framework client profiles for 3.5 and 4.0.
23+
There are helper powershell scripts in the root of this
24+
repository to assist with obtaining and installing these
25+
SDKs from Microsoft servers. Please see:
26+
- [install-dotnet-core-sdk-1.1.ps1](install-dotnet-core-sdk-1.1.ps1)
27+
- [install-net-framework-sdk-3.5.ps1](install-net-framework-sdk-3.5.ps1)
2128
- Binaries can be built with a Visual Studio or Rider installation
2229
- Binaries, packages and a release zip can be built via commandline
2330
- Ensure that you have a reasonably modern NodeJS installed (at least version 8+)

README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,20 @@ tracker is no longer accepting new issues but is available at
2727
https://issues.apache.org/jira/browse/LOG4NET for access to
2828
previous issues.
2929

30+
Developing
31+
==========
32+
33+
log4net targets a wide array of .net platforms, including some
34+
which are out of support from Microsoft, making it difficult to
35+
install relevant SDKs and build for those targets. In particular,
36+
older Client Profile .NET Framework targets and dotnet core 1.1
37+
may be installed by using the bundled helper scripts:
38+
39+
- [install-net-framework-sdk-3.5.ps1]()
40+
- [install-dotnet-core-sdk-1.1.ps1]()
41+
42+
These scripts download the relevant installers from Microsoft servers,
43+
but you run them at your own risk.
44+
3045
Please see [CONTRIBUTING.md](CONTRIBUTING.md) and
31-
[BUILDING.md](BUILDING.md)
46+
[BUILDING.md](BUILDING.md)

install-dotnet-core-sdk-1.1.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$installer="dotnet-dev-win-x64.1.1.14.exe"
2+
Write-Host "Downloading $installer"
3+
Invoke-WebRequest -Uri "https://download.visualstudio.microsoft.com/download/pr/c6b9a396-5e7a-4b91-86f6-f9e8df3bf1dd/6d61addfd6069e404981bede03f8f4f9/$installer" -OutFile $installer
4+
Write-Host "Running $installer"
5+
Start-Process -FilePath $installer -ArgumentList "/wait","/passive" -Wait
6+
Write-Host "dotnet core sdk 1.1 installed"
7+
File renamed without changes.

local-tasks/zip.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const
22
gulp = requireModule("gulp"),
33
promisify = requireModule("promisify-stream"),
4-
readNuspecVersion = requireModule("read-nuspec-version"),
4+
readCsProjVersion = requireModule("read-csproj-version"),
55
target = "build/artifacts",
66
zip = require("gulp-zip");
77

@@ -38,5 +38,5 @@ gulp.task("zip-source", async () => {
3838
});
3939

4040
function readVersion() {
41-
return readNuspecVersion("log4net.nuspec");
41+
return readCsProjVersion("src/log4net/log4net.csproj");
4242
}

log4net.nuspec

-127
This file was deleted.

package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
"scripts": {
66
"test": "cross-env NUNIT_PROCESS=Single MAX_CONCURRENCY=1 run-s clean-build \"zarro test-dotnet\"",
77
"clean-build": "rimraf build",
8-
"build": "run-s \"zarro build\"",
9-
"build-release": "cross-env BUILD_CONFIGURATION=Release run-s \"zarro build\"",
8+
"build": "run-s clean-build \"zarro build\"",
9+
"build-release": "cross-env BUILD_CONFIGURATION=Release run-s clean-build \"zarro build\"",
1010
"build-site": "run-s \"zarro build-site\"",
11-
"pack": "cross-env PACKAGE_TARGET_FOLDER=build/artifacts PACK_INCREMENT_VERSION=false run-s \"zarro pack\"",
1211
"zip": "run-s \"zarro zip\"",
1312
"dump-env": "node -e \"console.log(process.env);\"",
14-
"release": "run-s clean-build build-release pack zip",
13+
"release": "run-s build-release zip",
1514
"zarro": "cross-env BUILD_INCLUDE=src/log4net.sln zarro"
1615
},
1716
"repository": {
@@ -29,7 +28,7 @@
2928
"gulp-zip": "^5.0.1",
3029
"npm-run-all": "^4.1.5",
3130
"rimraf": "^3.0.2",
32-
"which": "^2.0.2",
33-
"zarro": "^1.76.0"
31+
"zarro": "^1.77.0",
32+
"which": "^2.0.2"
3433
}
3534
}

src/log4net.Tests/Appender/AdoNetAppenderTest.cs

+27
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

+4-2
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

0 commit comments

Comments
 (0)