Skip to content

Commit 869aa30

Browse files
author
mwatson
committed
Changes to allow net45 to work properly with new projects
1 parent a8ae6ad commit 869aa30

21 files changed

+86
-56
lines changed

Src/StackifyLib.AspNetCore/StackifyLib.AspNetCore.csproj

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<AssemblyTitle>StackifyLib for AspNetCore</AssemblyTitle>
55
<VersionPrefix>2.0.0-beta1</VersionPrefix>
6-
<TargetFramework>netstandard1.6</TargetFramework>
6+
<TargetFrameworks>netstandard1.3;net451</TargetFrameworks>
77
<AssemblyName>StackifyLib.AspNetCore</AssemblyName>
88
<PackageId>StackifyLib.AspNetCore</PackageId>
99
<PackageTags>stackify;metrics;errors;logs</PackageTags>
@@ -18,7 +18,18 @@
1818
<ProjectReference Include="..\StackifyLib\StackifyLib.csproj" />
1919
</ItemGroup>
2020

21-
<ItemGroup>
21+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
22+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.1" />
23+
<PackageReference Include="System.ComponentModel" Version="4.3.0" />
24+
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.0.2" />
25+
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="1.0.2" />
26+
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="1.0.2" />
27+
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="1.0.2" />
28+
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.0.3" />
29+
</ItemGroup>
30+
31+
32+
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
2233
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.1" />
2334
<PackageReference Include="System.ComponentModel" Version="4.3.0" />
2435
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.0.2" />

Src/StackifyLib.CoreLogger/StackifyLib.CoreLogger.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<AssemblyTitle>Stackify .NET Core LoggerFactory</AssemblyTitle>
55
<VersionPrefix>2.0.0</VersionPrefix>
6-
<TargetFramework>netstandard1.6</TargetFramework>
6+
<TargetFrameworks>netstandard1.3;net45</TargetFrameworks>
77
<AssemblyName>StackifyLib.CoreLogger</AssemblyName>
88
<PackageId>StackifyLib.CoreLogger</PackageId>
99
<PackageTags>stackify;metrics;errors;logs</PackageTags>
@@ -18,8 +18,15 @@
1818
<ProjectReference Include="..\StackifyLib\StackifyLib.csproj" />
1919
</ItemGroup>
2020

21-
<ItemGroup>
21+
22+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
23+
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.2" />
24+
</ItemGroup>
25+
26+
27+
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
2228
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.2" />
2329
</ItemGroup>
2430

31+
2532
</Project>

Src/StackifyLib/Config.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using System.Text;
55
using System.Diagnostics;
6-
using Newtonsoft.Json;
76

87
namespace StackifyLib
98
{
@@ -14,7 +13,7 @@ namespace StackifyLib
1413
public class Config
1514
{
1615

17-
#if NETSTANDARD1_3
16+
#if NETSTANDARD1_3 || NET451
1817
private static Microsoft.Extensions.Configuration.IConfigurationRoot _Configuration = null;
1918

2019
public static void SetConfiguration(Microsoft.Extensions.Configuration.IConfigurationRoot configuration)
@@ -135,7 +134,7 @@ internal static string Get(string key, string defaultValue = null)
135134
}
136135
#endif
137136

138-
#if NET45 || NET40s
137+
#if NET451 || NET45 || NET40s
139138
v = System.Configuration.ConfigurationManager.AppSettings[key];
140139
#endif
141140

Src/StackifyLib/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static StackifyLib.StackifyError NewStackifyError(this Exception ex)
3737
}
3838
}
3939

40-
#if NETSTANDARD1_3
40+
#if NETSTANDARD1_3 || NET451
4141
public static void ConfigureStackifyLogging(this Microsoft.Extensions.Configuration.IConfigurationRoot configuration)
4242
{
4343
Config.SetConfiguration(configuration);

Src/StackifyLib/Internal/Logs/LogClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ private Models.LogMsgGroup CreateDefaultMsgGroup()
331331

332332
if (!_ServicePointSet)
333333
{
334-
#if NET45 || NET40
334+
#if NET451 || NET45 || NET40
335335
ServicePointManager.FindServicePoint(urlToUse, null).ConnectionLimit = 10;
336336
#endif
337337
_ServicePointSet = true;

Src/StackifyLib/Internal/Logs/LogQueue.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using StackifyLib.Models;
88
using StackifyLib.Utils;
99

10-
#if NET45 || NET40
10+
#if NET451 || NET45 || NET40
1111
using System.Runtime.Remoting.Messaging;
1212
using StackifyLib.Web;
1313
#endif
@@ -97,7 +97,7 @@ public void QueueLogMessage(Models.LogMsg msg)
9797
{
9898
}
9999

100-
#if NET45 || NET40
100+
#if NET451 || NET45 || NET40
101101
try
102102
{
103103
if (string.IsNullOrEmpty(msg.TransID))
@@ -491,7 +491,7 @@ public void Stop()
491491
//wait for it to finish up to 5 seconds
492492
while (_UploadingNow && DateTime.UtcNow < stopWaiting)
493493
{
494-
#if NET45 || NET40
494+
#if NET451 || NET45 || NET40
495495
System.Threading.Thread.Sleep(10);
496496
#else
497497
Task.Delay(10).Wait();

Src/StackifyLib/Logger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public static List<TraceFrame> GetCurrentStackTrace(string declaringClassName, i
259259
{
260260
List<TraceFrame> frames = new List<TraceFrame>();
261261

262-
#if NET45 || NET40
262+
#if NET451 || NET45 || NET40
263263
try
264264
{
265265
//moves to the part of the trace where the declaring method starts then the other loop gets all the frames. This is to remove frames that happen within the logging library itself.

Src/StackifyLib/Models/EnvironmentDetail.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using System.Threading.Tasks;
88
using Newtonsoft.Json;
99
using StackifyLib.Utils;
10-
#if NET45 || NET40
10+
#if NET451 || NET45 || NET40
1111
using System.Linq;
1212
using System.Web.Hosting;
1313
using System.Management;
@@ -36,7 +36,7 @@ public static EnvironmentDetail Get(bool refresh)
3636
/// </summary>
3737
private void GetAzureInfo()
3838
{
39-
#if NET45 || NET40
39+
#if NET451 || NET45 || NET40
4040
if (registryAccessFailure)
4141
return;
4242

@@ -105,7 +105,7 @@ private void GetAzureInfo()
105105
/// <summary>
106106
/// Get the EC2 Instance name if it exists else null
107107
/// </summary>
108-
#if NET45 || NET40
108+
#if NET451 || NET45 || NET40
109109
public static string GetEC2InstanceId()
110110
{
111111
try
@@ -170,7 +170,7 @@ public static async Task<string> GetEC2InstanceId()
170170
/// </summary>
171171
private void IsWindowService()
172172
{
173-
#if NET45 || NET40
173+
#if NET451 || NET45 || NET40
174174
try
175175
{
176176
string query = "select DisplayName from Win32_Service WHERE ProcessID='" + System.Diagnostics.Process.GetCurrentProcess().Id + "'";
@@ -212,7 +212,7 @@ public EnvironmentDetail(bool loadDetails)
212212
return;
213213

214214
bool isWebRequest = false;
215-
#if NET45 || NET40
215+
#if NET451 || NET45 || NET40
216216
try
217217
{
218218
isWebRequest = AppDomain.CurrentDomain.FriendlyName.Contains("W3SVC");
@@ -293,7 +293,7 @@ public EnvironmentDetail(bool loadDetails)
293293
GetAzureInfo();
294294

295295

296-
#if NET45 || NET40
296+
#if NET451 || NET45 || NET40
297297
//Not a web app, check for windows service
298298
if (!Environment.UserInteractive && !AppDomain.CurrentDomain.FriendlyName.Contains("W3SVC"))
299299
{
@@ -302,7 +302,7 @@ public EnvironmentDetail(bool loadDetails)
302302
#endif
303303

304304

305-
#if NET45 || NET40
305+
#if NET451 || NET45 || NET40
306306

307307
DeviceName = GetEC2InstanceId() ?? Environment.MachineName;
308308
#else
@@ -311,7 +311,7 @@ public EnvironmentDetail(bool loadDetails)
311311
DeviceName = instanceID_task.Result ?? Process.GetCurrentProcess().MachineName;
312312
#endif
313313

314-
#if NET45 || NET40
314+
#if NET451 || NET45 || NET40
315315
if (string.IsNullOrEmpty(AppName) && !isWebRequest)
316316
{
317317
AppName = AppDomain.CurrentDomain.FriendlyName;
@@ -340,7 +340,7 @@ public EnvironmentDetail(bool loadDetails)
340340
StackifyLib.Utils.StackifyAPILogger.Log("Error figuring out app environment details\r\n" + ex.ToString(), true);
341341
}
342342

343-
#if NET45 || NET40
343+
#if NET451 || NET45 || NET40
344344
try
345345
{
346346

Src/StackifyLib/Models/ErrorItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public ErrorItem(Exception ex)
3232
}
3333

3434
Message = ex.Message;
35-
#if NET45 || NET40
35+
#if NET451 || NET45 || NET40
3636
if (ex is System.Data.SqlClient.SqlException)
3737
{
3838
System.Data.SqlClient.SqlException sql = ex as System.Data.SqlClient.SqlException;
@@ -149,7 +149,7 @@ private void AddTraceFrames(Exception ex)
149149
}
150150
}
151151

152-
#if NET45 || NET40
152+
#if NET451 || NET45 || NET40
153153
var stackTrace2 = new StackTrace(true);
154154
var allFrames = stackTrace2.GetFrames();
155155

@@ -199,7 +199,7 @@ public static string GetMethodFullName(MethodBase method, bool simpleMethodNames
199199
if (method == null)
200200
return "Unknown";
201201

202-
#if NET45 || NET40
202+
#if NET451 || NET45 || NET40
203203
if (method.ReflectedType != null)
204204
{
205205
if (simpleMethodNames)

Src/StackifyLib/Models/WebRequestDetail.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
using Newtonsoft.Json;
99

10-
#if NET45 || NET40
10+
#if NET451 || NET45 || NET40
1111
using System.Web;
1212
using System.Web.Routing;
1313
using StackifyLib.Web;
@@ -29,7 +29,7 @@ public WebRequestDetail(StackifyError error)
2929
{
3030
_Error = error;
3131

32-
#if NET45 || NET40
32+
#if NET451 || NET45 || NET40
3333
if (System.Web.HttpContext.Current != null)
3434
{
3535
Load(System.Web.HttpContext.Current);
@@ -93,7 +93,7 @@ public WebRequestDetail(StackifyError error)
9393

9494

9595

96-
#if NET45 || NET40
96+
#if NET451 || NET45 || NET40
9797
private void Load(HttpContext context)
9898
{
9999
if (context == null || context.Request == null)
@@ -248,7 +248,7 @@ internal static void AddKey(string key, string value, Dictionary<string, string>
248248
dictionary[key] = value;
249249
}
250250

251-
#if NET45 || NET40
251+
#if NET451 || NET45 || NET40
252252
internal static Dictionary<string, string> ToKeyValues(HttpCookieCollection collection, List<string> goodKeys, List<string> badKeys)
253253
{
254254
var keys = collection.AllKeys;

0 commit comments

Comments
 (0)