Skip to content

Commit 27def4d

Browse files
committed
Added build configurations, and compiler directives, to build for .Net 3.5, 4 and 4.5.2.
1 parent 71dbf87 commit 27def4d

10 files changed

Lines changed: 135 additions & 25 deletions

File tree

Take2/NuLog.CLI.PerfTune/NuLog.CLI.PerfTune.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@
4242
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
4343
<Prefer32Bit>true</Prefer32Bit>
4444
</PropertyGroup>
45+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-4|AnyCPU'">
46+
<OutputPath>bin\Release-4\</OutputPath>
47+
<DefineConstants>TRACE</DefineConstants>
48+
<Optimize>true</Optimize>
49+
<DebugType>pdbonly</DebugType>
50+
<PlatformTarget>AnyCPU</PlatformTarget>
51+
<ErrorReport>prompt</ErrorReport>
52+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
53+
<Prefer32Bit>true</Prefer32Bit>
54+
</PropertyGroup>
55+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-4.5.2|AnyCPU'">
56+
<OutputPath>bin\Release-4.5.2\</OutputPath>
57+
<DefineConstants>TRACE</DefineConstants>
58+
<Optimize>true</Optimize>
59+
<DebugType>pdbonly</DebugType>
60+
<PlatformTarget>AnyCPU</PlatformTarget>
61+
<ErrorReport>prompt</ErrorReport>
62+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
63+
<Prefer32Bit>true</Prefer32Bit>
64+
</PropertyGroup>
4565
<ItemGroup>
4666
<Reference Include="System" />
4767
<Reference Include="System.Core" />

Take2/NuLog.Tests/NuLog.Tests.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@
4141
<ErrorReport>prompt</ErrorReport>
4242
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
4343
</PropertyGroup>
44+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-4|AnyCPU'">
45+
<OutputPath>bin\Release-4\</OutputPath>
46+
<DefineConstants>TRACE</DefineConstants>
47+
<Optimize>true</Optimize>
48+
<DebugType>pdbonly</DebugType>
49+
<PlatformTarget>AnyCPU</PlatformTarget>
50+
<ErrorReport>prompt</ErrorReport>
51+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
52+
</PropertyGroup>
53+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-4.5.2|AnyCPU'">
54+
<OutputPath>bin\Release-4.5.2\</OutputPath>
55+
<DefineConstants>TRACE</DefineConstants>
56+
<Optimize>true</Optimize>
57+
<DebugType>pdbonly</DebugType>
58+
<PlatformTarget>AnyCPU</PlatformTarget>
59+
<ErrorReport>prompt</ErrorReport>
60+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
61+
</PropertyGroup>
4462
<ItemGroup>
4563
<Reference Include="FakeItEasy, Version=2.3.2.0, Culture=neutral, PublicKeyToken=eff28e2146d5fd2c, processorArchitecture=MSIL">
4664
<HintPath>..\packages\FakeItEasy.2.3.2\lib\net40\FakeItEasy.dll</HintPath>

Take2/NuLog.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Global
1717
Debug|Any CPU = Debug|Any CPU
1818
Release|Any CPU = Release|Any CPU
1919
Release-3.5|Any CPU = Release-3.5|Any CPU
20+
Release-4.5.2|Any CPU = Release-4.5.2|Any CPU
21+
Release-4|Any CPU = Release-4|Any CPU
2022
EndGlobalSection
2123
GlobalSection(ProjectConfigurationPlatforms) = postSolution
2224
{100467BE-E1B1-4D5A-A40B-CA633015EC42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -25,18 +27,30 @@ Global
2527
{100467BE-E1B1-4D5A-A40B-CA633015EC42}.Release|Any CPU.Build.0 = Release|Any CPU
2628
{100467BE-E1B1-4D5A-A40B-CA633015EC42}.Release-3.5|Any CPU.ActiveCfg = Release-3.5|Any CPU
2729
{100467BE-E1B1-4D5A-A40B-CA633015EC42}.Release-3.5|Any CPU.Build.0 = Release-3.5|Any CPU
30+
{100467BE-E1B1-4D5A-A40B-CA633015EC42}.Release-4.5.2|Any CPU.ActiveCfg = Release-4.5.2|Any CPU
31+
{100467BE-E1B1-4D5A-A40B-CA633015EC42}.Release-4.5.2|Any CPU.Build.0 = Release-4.5.2|Any CPU
32+
{100467BE-E1B1-4D5A-A40B-CA633015EC42}.Release-4|Any CPU.ActiveCfg = Release-4|Any CPU
33+
{100467BE-E1B1-4D5A-A40B-CA633015EC42}.Release-4|Any CPU.Build.0 = Release-4|Any CPU
2834
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2935
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
3036
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
3137
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Release|Any CPU.Build.0 = Release|Any CPU
3238
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Release-3.5|Any CPU.ActiveCfg = Release-3.5|Any CPU
3339
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Release-3.5|Any CPU.Build.0 = Release-3.5|Any CPU
40+
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Release-4.5.2|Any CPU.ActiveCfg = Release-4.5.2|Any CPU
41+
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Release-4.5.2|Any CPU.Build.0 = Release-4.5.2|Any CPU
42+
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Release-4|Any CPU.ActiveCfg = Release-4|Any CPU
43+
{ED0E44F6-7945-4B80-BD29-168065AD01D5}.Release-4|Any CPU.Build.0 = Release-4|Any CPU
3444
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3545
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
3646
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
3747
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Release|Any CPU.Build.0 = Release|Any CPU
3848
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Release-3.5|Any CPU.ActiveCfg = Release-3.5|Any CPU
3949
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Release-3.5|Any CPU.Build.0 = Release-3.5|Any CPU
50+
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Release-4.5.2|Any CPU.ActiveCfg = Release-4.5.2|Any CPU
51+
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Release-4.5.2|Any CPU.Build.0 = Release-4.5.2|Any CPU
52+
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Release-4|Any CPU.ActiveCfg = Release-4|Any CPU
53+
{40A62D51-DE30-4C8A-BD5F-157189E0C8B5}.Release-4|Any CPU.Build.0 = Release-4|Any CPU
4054
EndGlobalSection
4155
GlobalSection(SolutionProperties) = preSolution
4256
HideSolutionNode = FALSE

Take2/NuLog/Dispatchers/StandardDispatcher.cs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
using NuLog.Dispatchers.TagRouters;
66
using NuLog.Loggers;
77
using System;
8-
9-
//TODO: using System.Collections.Concurrent;
108
using System.Collections.Generic;
119
using System.Diagnostics;
1210
using System.Linq;
1311
using System.Threading;
1412

13+
#if !PRENET4
14+
15+
using System.Collections.Concurrent;
16+
17+
#endif
18+
1519
namespace NuLog.Dispatchers
1620
{
1721
/// <summary>
@@ -37,8 +41,11 @@ public class StandardDispatcher : IDispatcher
3741
/// <summary>
3842
/// A queue for storing log events to be dispatched.
3943
/// </summary>
40-
//TODO: private readonly ConcurrentQueue<ILogEvent> logEventQueue;
44+
#if PRENET4
4145
private readonly Queue<ILogEvent> logEventQueue;
46+
#else
47+
private readonly ConcurrentQueue<ILogEvent> logEventQueue;
48+
#endif
4249

4350
/// <summary>
4451
/// The timer for processing the log queue.
@@ -62,8 +69,11 @@ public StandardDispatcher(IEnumerable<ITarget> targets, ITagRouter tagRouter, IF
6269

6370
this.fallbackLogger = fallbackLogger;
6471

65-
//TODO: this.logEventQueue = new ConcurrentQueue<ILogEvent>();
72+
#if PRENET4
6673
this.logEventQueue = new Queue<ILogEvent>();
74+
#else
75+
this.logEventQueue = new ConcurrentQueue<ILogEvent>();
76+
#endif
6777

6878
this.logEventQueueTimer = new Timer(OnLogQueueTimerElapsed, this, 200, 200);
6979
}
@@ -192,16 +202,19 @@ private static void OnLogQueueTimerElapsed(object dispatcherInstance)
192202
/// </summary>
193203
protected void ProcessLogQueue()
194204
{
195-
//TODO: ILogEvent logEvent;
196-
//while (this.logEventQueue.TryDequeue(out logEvent))
197-
//{
198-
// DispatchNow(logEvent);
199-
//}
205+
#if PRENET4
200206
while (this.logEventQueue.Count > 0)
201207
{
202208
var logEvent = this.logEventQueue.Dequeue();
203209
DispatchNow(logEvent);
204210
}
211+
#else
212+
ILogEvent logEvent;
213+
while (this.logEventQueue.TryDequeue(out logEvent))
214+
{
215+
DispatchNow(logEvent);
216+
}
217+
#endif
205218
}
206219

207220
#endregion LogEvent Queue Management

Take2/NuLog/Factories/StandardLoggerFactory.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
using System;
1616
using System.Collections.Generic;
1717

18+
#if !PRENET45
19+
using System.Collections.ObjectModel;
20+
#endif
21+
1822
namespace NuLog.Factories
1923
{
2024
/// <summary>
@@ -118,8 +122,11 @@ protected IDictionary<string, object> DefaultMetaData
118122
{
119123
if (_defaultMetaData == null)
120124
{
121-
//TODO: _defaultMetaData = new ReadOnlyDictionary<string, object>(ToMetaData(Config.MetaData));
125+
#if PRENET45
122126
_defaultMetaData = new Dictionary<string, object>(ToMetaData(Config.MetaData));
127+
#else
128+
_defaultMetaData = new ReadOnlyDictionary<string, object>(ToMetaData(Config.MetaData));
129+
#endif
123130
}
124131
}
125132
}

Take2/NuLog/FallbackLoggers/StandardFallbackLoggerBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ private static string GetMessage(ILogEvent logEvent)
3636

3737
private static string JoinTags(ILogEvent logEvent)
3838
{
39-
//TODO: return logEvent.Tags != null ? string.Join(",", logEvent.Tags) : string.Empty;
39+
#if PRENET4
4040
return logEvent.Tags != null ? string.Join(",", logEvent.Tags.ToArray()) : string.Empty;
41+
#else
42+
return logEvent.Tags != null ? string.Join(",", logEvent.Tags) : string.Empty;
43+
#endif
4144
}
4245

4346
private static string GetExceptionMessage(ILogEvent logEvent)

Take2/NuLog/Layouts/StandardLayout.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ protected virtual object GetSpecialParameter(LogEvent logEvent, LayoutParameter
128128
switch (parameter.Path)
129129
{
130130
case "Tags":
131-
//TODO: return logEvent.Tags != null ? string.Join(",", logEvent.Tags) : string.Empty;
131+
#if PRENET4
132132
return logEvent.Tags != null ? string.Join(",", logEvent.Tags.ToArray()) : string.Empty;
133+
#else
134+
return logEvent.Tags != null ? string.Join(",", logEvent.Tags) : string.Empty;
135+
#endif
133136

134137
case "Exception":
135138
return FormatException(logEvent.Exception);

Take2/NuLog/NuLog.csproj

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>NuLog</RootNamespace>
1111
<AssemblyName>NuLog</AssemblyName>
12-
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<TargetFrameworkProfile />
1515
</PropertyGroup>
@@ -18,9 +18,10 @@
1818
<DebugType>full</DebugType>
1919
<Optimize>false</Optimize>
2020
<OutputPath>bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<DefineConstants>TRACE;DEBUG</DefineConstants>
2222
<ErrorReport>prompt</ErrorReport>
2323
<WarningLevel>4</WarningLevel>
24+
<Prefer32Bit>false</Prefer32Bit>
2425
</PropertyGroup>
2526
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2627
<DebugType>pdbonly</DebugType>
@@ -29,15 +30,40 @@
2930
<DefineConstants>TRACE</DefineConstants>
3031
<ErrorReport>prompt</ErrorReport>
3132
<WarningLevel>4</WarningLevel>
33+
<Prefer32Bit>false</Prefer32Bit>
3234
</PropertyGroup>
3335
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-3.5|AnyCPU'">
3436
<OutputPath>bin\Release-3.5\</OutputPath>
37+
<DefineConstants>TRACE;PRENET4 PRENET45</DefineConstants>
38+
<Optimize>true</Optimize>
39+
<DebugType>pdbonly</DebugType>
40+
<PlatformTarget>AnyCPU</PlatformTarget>
41+
<ErrorReport>prompt</ErrorReport>
42+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
43+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
44+
<Prefer32Bit>false</Prefer32Bit>
45+
</PropertyGroup>
46+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-4|AnyCPU'">
47+
<OutputPath>bin\Release-4\</OutputPath>
48+
<DefineConstants>TRACE;PRENET45</DefineConstants>
49+
<Optimize>true</Optimize>
50+
<DebugType>pdbonly</DebugType>
51+
<PlatformTarget>AnyCPU</PlatformTarget>
52+
<ErrorReport>prompt</ErrorReport>
53+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
54+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
55+
<Prefer32Bit>false</Prefer32Bit>
56+
</PropertyGroup>
57+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-4.5.2|AnyCPU'">
58+
<OutputPath>bin\Release-4.5.2\</OutputPath>
3559
<DefineConstants>TRACE</DefineConstants>
3660
<Optimize>true</Optimize>
3761
<DebugType>pdbonly</DebugType>
3862
<PlatformTarget>AnyCPU</PlatformTarget>
3963
<ErrorReport>prompt</ErrorReport>
4064
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
65+
<Prefer32Bit>false</Prefer32Bit>
66+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
4167
</PropertyGroup>
4268
<ItemGroup>
4369
<Reference Include="System" />
@@ -108,7 +134,7 @@
108134
</ItemGroup>
109135
<ItemGroup />
110136
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
111-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
137+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
112138
Other similar extension points exist, see Microsoft.Common.targets.
113139
<Target Name="BeforeBuild">
114140
</Target>

Take2/NuLog/Targets/EventLogTarget.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,8 @@ public override void Configure(TargetConfig config)
6262

6363
// Parse out the entry type
6464
var entryTypeRaw = GetProperty<string>(config, "entryType");
65-
//EventLogEntryType entryType;
66-
//TODO: if (Enum.TryParse(entryTypeRaw, out entryType))
67-
//{
68-
// this.entryType = entryType;
69-
//}
70-
//else
71-
//{
72-
// this.entryType = EventLogEntryType.Information;
73-
//}
65+
66+
#if PRENET4
7467
if (string.IsNullOrEmpty(entryTypeRaw) == false)
7568
{
7669
this.entryType = (EventLogEntryType)Enum.Parse(EventLogEntryTypeType, entryTypeRaw);
@@ -79,6 +72,17 @@ public override void Configure(TargetConfig config)
7972
{
8073
this.entryType = EventLogEntryType.Information;
8174
}
75+
#else
76+
EventLogEntryType entryType;
77+
if (Enum.TryParse(entryTypeRaw, out entryType))
78+
{
79+
this.entryType = entryType;
80+
}
81+
else
82+
{
83+
this.entryType = EventLogEntryType.Information;
84+
}
85+
#endif
8286

8387
// Let the base configure
8488
base.Configure(config);

Take2/NuLog/Targets/SmtpClientShim.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public SmtpClientShim()
2424

2525
public void Dispose()
2626
{
27-
//TODO: this.smtpClient.Dispose();
27+
#if !PRENET4
28+
this.smtpClient.Dispose();
29+
#endif
2830
}
2931

3032
public void Send(MailMessage mailMessage)

0 commit comments

Comments
 (0)