Skip to content

Commit aff3340

Browse files
committed
.Net 4.5 compatibility
Signed-off-by: Dima Enns <[email protected]>
1 parent 1637d7e commit aff3340

File tree

4 files changed

+104
-118
lines changed

4 files changed

+104
-118
lines changed

Sources/LambdaConverters.Deployment/Program.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ static int Main([NotNull] string[] args)
1515
{
1616
try
1717
{
18-
string assemblyPath;
18+
string assemblyPath45;
19+
string assemblyPath46;
1920
bool isReleaseBuild;
2021
string nugetPath;
2122
string nuspecPath;
2223
string nuspecAnnotationsPath;
23-
GetPaths(out assemblyPath, out isReleaseBuild, out nugetPath, out nuspecPath, out nuspecAnnotationsPath);
24+
GetPaths(out assemblyPath45, out assemblyPath46, out isReleaseBuild, out nugetPath, out nuspecPath, out nuspecAnnotationsPath);
2425

2526
if (isReleaseBuild)
2627
{
@@ -30,11 +31,11 @@ static int Main([NotNull] string[] args)
3031
}
3132

3233
var snkPath = args[0];
33-
ResignAssembly(assemblyPath, snkPath);
34+
ResignAssembly(assemblyPath45, assemblyPath46, snkPath);
3435
}
3536

3637
string packageFileName;
37-
UpdateNuspec(assemblyPath, nuspecPath, out packageFileName);
38+
UpdateNuspec(assemblyPath45, assemblyPath46, nuspecPath, out packageFileName);
3839

3940
BuildPackages(nugetPath, nuspecPath, nuspecAnnotationsPath);
4041

@@ -56,7 +57,8 @@ static int Main([NotNull] string[] args)
5657

5758
[Pure]
5859
static void GetPaths(
59-
[NotNull] out string assemblyPath,
60+
[NotNull] out string assemblyPath45,
61+
[NotNull] out string assemblyPath46,
6062
out bool isReleaseBuild,
6163
[NotNull] out string nugetPath,
6264
[NotNull] out string nuspecPath,
@@ -76,29 +78,33 @@ static void GetPaths(
7678

7779
nugetPath = Path.Combine(solutionDirectory, "NuGet.exe");
7880

79-
assemblyPath = Path.Combine(solutionDirectory, "LambdaConverters.Wpf", "bin", executionDirectory, "LambdaConverters.Wpf.dll");
81+
assemblyPath45 = Path.Combine(solutionDirectory, "LambdaConverters.Wpf", "bin", executionDirectory, "net45", "LambdaConverters.Wpf.dll");
82+
83+
assemblyPath46 = Path.Combine(solutionDirectory, "LambdaConverters.Wpf", "bin", executionDirectory, "net46", "LambdaConverters.Wpf.dll");
8084

8185
nuspecPath = Path.Combine(executionDirectoryPath, "LambdaConverters.nuspec");
8286

8387
nuspecAnnotationsPath = Path.Combine(executionDirectoryPath, "LambdaConverters.Annotations.nuspec");
8488
}
8589

86-
static void ResignAssembly([NotNull] string assemblyPath, [NotNull] string snkPath)
90+
static void ResignAssembly([NotNull] string assemblyPath45, string assemblyPath46, [NotNull] string snkPath)
8791
{
8892
Console.WriteLine("Resigning assembly...");
8993

9094
Debug.Assert(Settings.Default != null);
9195

9296
Console.WriteLine($"Tool path: {Settings.Default.SnPath}");
9397

94-
RunConsoleApplication($"\"{Settings.Default.SnPath}\"", $"-R \"{assemblyPath}\" \"{snkPath}\"");
98+
RunConsoleApplication($"\"{Settings.Default.SnPath}\"", $"-R \"{assemblyPath45}\" \"{snkPath}\"");
99+
100+
RunConsoleApplication($"\"{Settings.Default.SnPath}\"", $"-R \"{assemblyPath46}\" \"{snkPath}\"");
95101
}
96102

97-
static void UpdateNuspec([NotNull] string assemblyPath, [NotNull] string nuspecPath, [NotNull] out string packageFileName)
103+
static void UpdateNuspec([NotNull] string assemblyPath45, string assemblyPath46, [NotNull] string nuspecPath, [NotNull] out string packageFileName)
98104
{
99105
Console.Write("Updating nuspec...");
100106

101-
var assembly = Assembly.ReflectionOnlyLoadFrom(assemblyPath);
107+
var assembly = Assembly.ReflectionOnlyLoadFrom(assemblyPath45);
102108
Debug.Assert(assembly != null);
103109

104110
var nuspec = XDocument.Load(nuspecPath);
@@ -112,14 +118,18 @@ static void UpdateNuspec([NotNull] string assemblyPath, [NotNull] string nuspecP
112118
Debug.Assert(versionElement != null);
113119
Debug.Assert(fileVersionAttributeData != null);
114120
Debug.Assert(fileVersionAttributeData.ConstructorArguments[0].Value is string);
115-
versionElement.Value = (string)fileVersionAttributeData.ConstructorArguments[0].Value;
121+
//versionElement.Value = (string)fileVersionAttributeData.ConstructorArguments[0].Value;
116122

117-
const string target = @"lib\net46";
123+
const string targetNet45 = @"lib\net45";
124+
const string targetNet46 = @"lib\net46";
118125
nuspec.Root.Element("files")?
119126
.Add(
120-
new XElement("file", new XAttribute("src", assemblyPath), new XAttribute("target", target)),
121-
new XElement("file", new XAttribute("src", Path.ChangeExtension(assemblyPath, "pdb")), new XAttribute("target", target)),
122-
new XElement("file", new XAttribute("src", Path.ChangeExtension(assemblyPath, "xml")), new XAttribute("target", target)));
127+
new XElement("file", new XAttribute("src", assemblyPath45), new XAttribute("target", targetNet45)),
128+
new XElement("file", new XAttribute("src", Path.ChangeExtension(assemblyPath45, "pdb")), new XAttribute("target", targetNet45)),
129+
new XElement("file", new XAttribute("src", Path.ChangeExtension(assemblyPath45, "xml")), new XAttribute("target", targetNet45)),
130+
new XElement("file", new XAttribute("src", assemblyPath46), new XAttribute("target", targetNet46)),
131+
new XElement("file", new XAttribute("src", Path.ChangeExtension(assemblyPath46, "pdb")), new XAttribute("target", targetNet46)),
132+
new XElement("file", new XAttribute("src", Path.ChangeExtension(assemblyPath46, "xml")), new XAttribute("target", targetNet46)));
123133

124134
packageFileName = $"{(string)metadataElement.Element("id")}.{(string)metadataElement.Element("version")}.nupkg";
125135

Sources/LambdaConverters.Wpf/EventSource.cs

Lines changed: 76 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public static class Keywords
3232
Message = "The {0} is null, conversion result is a value according to the specified error strategy ({1}).",
3333
Level = EventLevel.Warning,
3434
Keywords = Keywords.Converters,
35-
Opcode = EventOpcode.Info,
36-
Channel = EventChannel.Operational
35+
Opcode = EventOpcode.Info
36+
#if NET46
37+
,Channel = EventChannel.Operational
38+
#endif
3739
)]
3840
public void MissingConvertFunction(
3941
string callback,
@@ -60,8 +62,10 @@ public void MissingConvertFunction(
6062
Message = "The {0} is null, back conversion result is a value according to the specified error strategy ({1}).",
6163
Level = EventLevel.Warning,
6264
Keywords = Keywords.Converters,
63-
Opcode = EventOpcode.Info,
64-
Channel = EventChannel.Operational
65+
Opcode = EventOpcode.Info
66+
#if NET46
67+
,Channel = EventChannel.Operational
68+
#endif
6569
)]
6670
public void MissingConvertBackFunction(
6771
string callback,
@@ -88,8 +92,10 @@ public void MissingConvertBackFunction(
8892
Message = "The requested target type ({0}) is not assignable from the specified output type ({1}), conversion result is a value according to the specified error strategy ({2}).",
8993
Level = EventLevel.Warning,
9094
Keywords = Keywords.Converters,
91-
Opcode = EventOpcode.Info,
92-
Channel = EventChannel.Operational
95+
Opcode = EventOpcode.Info
96+
#if NET46
97+
,Channel = EventChannel.Operational
98+
#endif
9399
)]
94100
public void NonAssignableTargetType(
95101
string targetType,
@@ -118,8 +124,10 @@ public void NonAssignableTargetType(
118124
Message = "The requested target type ({0}) is not assignable from the specified input type ({1}), back conversion result is a value according to the specified error strategy ({2}).",
119125
Level = EventLevel.Warning,
120126
Keywords = Keywords.Converters,
121-
Opcode = EventOpcode.Info,
122-
Channel = EventChannel.Operational
127+
Opcode = EventOpcode.Info
128+
#if NET46
129+
,Channel = EventChannel.Operational
130+
#endif
123131
)]
124132
public void NonAssignableTargetTypeForBackConversion(
125133
string targetType,
@@ -148,8 +156,10 @@ public void NonAssignableTargetTypeForBackConversion(
148156
Message = "The requested target type ({0}) at the position {1} is not assignable from the specified input type ({2}), back conversion result is a value according to the specified error strategy ({3}).",
149157
Level = EventLevel.Warning,
150158
Keywords = Keywords.Converters,
151-
Opcode = EventOpcode.Info,
152-
Channel = EventChannel.Operational
159+
Opcode = EventOpcode.Info
160+
#if NET46
161+
,Channel = EventChannel.Operational
162+
#endif
153163
)]
154164
public void NonAssignableTargetTypeAtPositionForBackConversion(
155165
string targetType,
@@ -180,8 +190,10 @@ public void NonAssignableTargetTypeAtPositionForBackConversion(
180190
Message = "The provided values are null, conversion result is a value according to the specified error strategy ({0}).",
181191
Level = EventLevel.Warning,
182192
Keywords = Keywords.Converters,
183-
Opcode = EventOpcode.Info,
184-
Channel = EventChannel.Operational
193+
Opcode = EventOpcode.Info
194+
#if NET46
195+
,Channel = EventChannel.Operational
196+
#endif
185197
)]
186198
public void NullValues(
187199
string errorStrategy,
@@ -206,8 +218,10 @@ public void NullValues(
206218
Message = "The target type is not requested.",
207219
Level = EventLevel.Informational,
208220
Keywords = Keywords.Converters,
209-
Opcode = EventOpcode.Info,
210-
Channel = EventChannel.Operational
221+
Opcode = EventOpcode.Info
222+
#if NET46
223+
,Channel = EventChannel.Operational
224+
#endif
211225
)]
212226
public void NonRequestedTargetType(
213227
[CallerMemberName] string memberName = null,
@@ -230,8 +244,10 @@ public void NonRequestedTargetType(
230244
Message = "The target type at the position {0} is not requested.",
231245
Level = EventLevel.Informational,
232246
Keywords = Keywords.Converters,
233-
Opcode = EventOpcode.Info,
234-
Channel = EventChannel.Operational
247+
Opcode = EventOpcode.Info
248+
#if NET46
249+
,Channel = EventChannel.Operational
250+
#endif
235251
)]
236252
public void NonRequestedTargetTypeAtPosition(
237253
int position,
@@ -256,8 +272,10 @@ public void NonRequestedTargetTypeAtPosition(
256272
Message = "A conversion parameter ({0}) is provided, use the appropriate converter, conversion result is a value according to the specified error strategy ({1}).",
257273
Level = EventLevel.Warning,
258274
Keywords = Keywords.Converters,
259-
Opcode = EventOpcode.Info,
260-
Channel = EventChannel.Operational
275+
Opcode = EventOpcode.Info
276+
#if NET46
277+
,Channel = EventChannel.Operational
278+
#endif
261279
)]
262280
public void ParameterInParameterlessConverter(
263281
string objectType,
@@ -284,8 +302,10 @@ public void ParameterInParameterlessConverter(
284302
Message = "A conversion parameter ({0}) is provided, use the appropriate converter, back conversion result is a value according to the specified error strategy ({1}).",
285303
Level = EventLevel.Warning,
286304
Keywords = Keywords.Converters,
287-
Opcode = EventOpcode.Info,
288-
Channel = EventChannel.Operational
305+
Opcode = EventOpcode.Info
306+
#if NET46
307+
,Channel = EventChannel.Operational
308+
#endif
289309
)]
290310
public void ParameterInParameterlessConverterForBackConversion(
291311
string objectType,
@@ -312,8 +332,10 @@ public void ParameterInParameterlessConverterForBackConversion(
312332
Message = "The value ({0}) cannot be cast to the specified input type ({1}), conversion result is a value according to the specified error strategy ({2}).",
313333
Level = EventLevel.Warning,
314334
Keywords = Keywords.Converters,
315-
Opcode = EventOpcode.Info,
316-
Channel = EventChannel.Operational
335+
Opcode = EventOpcode.Info
336+
#if NET46
337+
,Channel = EventChannel.Operational
338+
#endif
317339
)]
318340
public void UnableToCastToInputType(
319341
string objectType,
@@ -342,8 +364,10 @@ public void UnableToCastToInputType(
342364
Message = "The value ({0}) at the position {1} cannot be cast to the specified input type ({2}), conversion result is a value according to the specified error strategy ({3}).",
343365
Level = EventLevel.Warning,
344366
Keywords = Keywords.Converters,
345-
Opcode = EventOpcode.Info,
346-
Channel = EventChannel.Operational
367+
Opcode = EventOpcode.Info
368+
#if NET46
369+
,Channel = EventChannel.Operational
370+
#endif
347371
)]
348372
public void UnableToCastAtPositionToInputType(
349373
string objectType,
@@ -374,8 +398,10 @@ public void UnableToCastAtPositionToInputType(
374398
Message = "The value ({0}) cannot be cast to the specified output type ({1}), back conversion result is a value according to the specified error strategy ({2}).",
375399
Level = EventLevel.Warning,
376400
Keywords = Keywords.Converters,
377-
Opcode = EventOpcode.Info,
378-
Channel = EventChannel.Operational
401+
Opcode = EventOpcode.Info
402+
#if NET46
403+
,Channel = EventChannel.Operational
404+
#endif
379405
)]
380406
public void UnableToCastToOutputType(
381407
string objectType,
@@ -404,8 +430,10 @@ public void UnableToCastToOutputType(
404430
Message = "The parameter value ({0}) cannot be cast to the specified parameter type ({1}), conversion result is a value according to the specified error strategy ({2}).",
405431
Level = EventLevel.Warning,
406432
Keywords = Keywords.Converters,
407-
Opcode = EventOpcode.Info,
408-
Channel = EventChannel.Operational
433+
Opcode = EventOpcode.Info
434+
#if NET46
435+
,Channel = EventChannel.Operational
436+
#endif
409437
)]
410438
public void UnableToCastToParameterType(
411439
string objectType,
@@ -434,8 +462,10 @@ public void UnableToCastToParameterType(
434462
Message = "The parameter value ({0}) cannot be cast to the specified parameter type ({1}), back conversion result is a value according to the specified error strategy ({2}).",
435463
Level = EventLevel.Warning,
436464
Keywords = Keywords.Converters,
437-
Opcode = EventOpcode.Info,
438-
Channel = EventChannel.Operational
465+
Opcode = EventOpcode.Info
466+
#if NET46
467+
,Channel = EventChannel.Operational
468+
#endif
439469
)]
440470
public void UnableToCastToParameterTypeForBackConversion(
441471
string objectType,
@@ -464,8 +494,10 @@ public void UnableToCastToParameterTypeForBackConversion(
464494
Message = "The {0} is null, conversion result is a value according to the specified error strategy ({1}).",
465495
Level = EventLevel.Warning,
466496
Keywords = Keywords.Selectors,
467-
Opcode = EventOpcode.Info,
468-
Channel = EventChannel.Operational
497+
Opcode = EventOpcode.Info
498+
#if NET46
499+
,Channel = EventChannel.Operational
500+
#endif
469501
)]
470502
public void MissingSelectTemplateFunction(
471503
string callback,
@@ -492,8 +524,10 @@ public void MissingSelectTemplateFunction(
492524
Message = "The value ({0}) cannot be cast to the specified input type ({1}), conversion result is a value according to the specified error strategy ({2}).",
493525
Level = EventLevel.Warning,
494526
Keywords = Keywords.Selectors,
495-
Opcode = EventOpcode.Info,
496-
Channel = EventChannel.Operational
527+
Opcode = EventOpcode.Info
528+
#if NET46
529+
,Channel = EventChannel.Operational
530+
#endif
497531
)]
498532
public void UnableToCastToItemType(
499533
string itemType,
@@ -522,8 +556,10 @@ public void UnableToCastToItemType(
522556
Message = "The {0} is null, conversion result is a value according to the specified error strategy ({1}).",
523557
Level = EventLevel.Warning,
524558
Keywords = Keywords.Rules,
525-
Opcode = EventOpcode.Info,
526-
Channel = EventChannel.Operational
559+
Opcode = EventOpcode.Info
560+
#if NET46
561+
,Channel = EventChannel.Operational
562+
#endif
527563
)]
528564
public void MissingRuleFunction(
529565
string callback,
@@ -550,8 +586,10 @@ public void MissingRuleFunction(
550586
Message = "The value ({0}) cannot be cast to the specified input type ({1}), conversion result is a value according to the specified error strategy ({2}).",
551587
Level = EventLevel.Warning,
552588
Keywords = Keywords.Rules,
553-
Opcode = EventOpcode.Info,
554-
Channel = EventChannel.Operational
589+
Opcode = EventOpcode.Info
590+
#if NET46
591+
,Channel = EventChannel.Operational
592+
#endif
555593
)]
556594
public void UnableToCastToRuleInputType(
557595
string itemType,

0 commit comments

Comments
 (0)