Skip to content

Commit aa5da26

Browse files
committed
Make preprocessor directives more flexible
1 parent f0bf497 commit aa5da26

9 files changed

+18
-17
lines changed

src/EFCore.Tasks/Tasks/Internal/MsBuildUtilities.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#if NET472
4+
#if !NET
55
using System.Configuration;
66
#endif
77

src/EFCore.Tasks/Tasks/Internal/OperationTaskBase.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ protected override string GenerateCommandLineCommands()
193193
args.Add(runtimeFrameworkVersion);
194194
}
195195

196-
#if !NET10_0
197-
#elif NET472
196+
#if NET472
197+
#elif NET10_0
198+
#else
198199
#error Target framework needs to be updated here
199200
#endif
200201
args.Add(

src/ef/AppDomainOperationExecutor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#if NET472
4+
#if !NET
55
using System.Collections;
66
using System.Reflection;
77
using Microsoft.EntityFrameworkCore.Design;

src/ef/Commands/MigrationsBundleCommand.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected override void Validate()
2929
}
3030
}
3131

32-
#if NET472
32+
#if !NET
3333
protected override int Execute(string[] args)
3434
=> throw new CommandException(Resources.VersionRequired("6.0.0"));
3535
#else

src/ef/Commands/ProjectCommandBase.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
using Microsoft.DotNet.Cli.CommandLine;
66
using Microsoft.EntityFrameworkCore.Design;
77
using Microsoft.EntityFrameworkCore.Tools.Properties;
8-
#if NET472
9-
using System.Configuration;
10-
#else
8+
#if NET
119
using System.Runtime.Loader;
10+
#else
11+
using System.Configuration;
1212
#endif
1313

1414
namespace Microsoft.EntityFrameworkCore.Tools.Commands
@@ -81,7 +81,7 @@ protected IOperationExecutor CreateExecutor(string[] remainingArguments)
8181
Reporter.WriteWarning,
8282
Reporter.WriteInformation,
8383
Reporter.WriteVerbose);
84-
#if NET472
84+
#if !NET
8585
try
8686
{
8787
return new AppDomainOperationExecutor(

src/ef/ReflectionOperationExecutor.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System.Collections;
55
using System.Reflection;
6-
#if !NET472
6+
#if NET
77
using System.Runtime.Loader;
88
#endif
99
using Microsoft.EntityFrameworkCore.Design;
@@ -21,7 +21,7 @@ internal class ReflectionOperationExecutor : OperationExecutorBase
2121
private const string ResultHandlerTypeName = "Microsoft.EntityFrameworkCore.Design.OperationResultHandler";
2222
private readonly Type _resultHandlerType;
2323
private string? _efcoreVersion;
24-
#if !NET472
24+
#if NET
2525
private AssemblyLoadContext? _assemblyLoadContext;
2626
#endif
2727

@@ -55,7 +55,7 @@ public ReflectionOperationExecutor(
5555

5656
AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
5757

58-
#if !NET472
58+
#if NET
5959
_commandsAssembly = AssemblyLoadContext.LoadFromAssemblyName(new AssemblyName(DesignAssemblyName));
6060
#else
6161
if (DesignAssemblyPath != null)
@@ -97,7 +97,7 @@ public ReflectionOperationExecutor(
9797
_resultHandlerType = _commandsAssembly.GetType(ResultHandlerTypeName, throwOnError: true, ignoreCase: false)!;
9898
}
9999

100-
#if !NET472
100+
#if NET
101101
protected AssemblyLoadContext AssemblyLoadContext
102102
{
103103
get
@@ -133,7 +133,7 @@ public override string? EFCoreVersion
133133
}
134134

135135
Assembly? assembly = null;
136-
#if !NET472
136+
#if NET
137137
assembly = AssemblyLoadContext.LoadFromAssemblyName(new AssemblyName(DesignAssemblyName));
138138
#else
139139
if (DesignAssemblyPath != null)

src/ef/Utilities/CallContext.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#if !NET472
4+
#if NET
55
namespace System.Runtime.Remoting.Messaging
66
{
77
internal static class CallContext

src/ef/Utilities/CompilerError.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#if !NET472
4+
#if NET
55
namespace System.CodeDom.Compiler
66
{
77
internal class CompilerError

src/ef/Utilities/CompilerErrorCollection.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#if !NET472
4+
#if NET
55
namespace System.CodeDom.Compiler
66
{
77
internal class CompilerErrorCollection

0 commit comments

Comments
 (0)