Skip to content

Commit 0f6c8ae

Browse files
committed
Remove obsolete conditional compilation + errors fixed
1 parent 5ec4fc4 commit 0f6c8ae

File tree

16 files changed

+14
-136
lines changed

16 files changed

+14
-136
lines changed

Extensions/Xtensive.Orm.BulkOperations/Internals/Operation.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,7 @@ protected void EnsureTransactionIsStarted()
6868
public QueryTranslationResult GetRequest(IQueryable<T> query) => QueryBuilder.TranslateQuery(query);
6969

7070
public QueryTranslationResult GetRequest(Type type, IQueryable query) =>
71-
#if NET8_0_OR_GREATER
7271
(QueryTranslationResult) WellKnownMembers.TranslateQueryMethod.CachedMakeGenericMethodInvoker(type).Invoke(QueryBuilder, query);
73-
#else
74-
(QueryTranslationResult) WellKnownMembers.TranslateQueryMethod.CachedMakeGenericMethod(type).Invoke(QueryBuilder, new object[] {query});
75-
#endif
7672

7773
public TypeInfo GetTypeInfo(Type entityType) =>
7874
Session.Domain.Model.Hierarchies.SelectMany(a => a.Types).Single(a => a.UnderlyingType == entityType);

Extensions/Xtensive.Orm.Localization/Configuration/LocalizationConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static LocalizationConfiguration Load()
7979
/// </returns>
8080
public static LocalizationConfiguration Load(string sectionName)
8181
{
82-
var section = (ConfigurationSection) ConfigurationManager.GetSection(sectionName);
82+
var section = (ConfigurationSection) System.Configuration.ConfigurationManager.GetSection(sectionName);
8383
return GetConfigurationFromSection(section);
8484
}
8585

Extensions/Xtensive.Orm.Reprocessing/Configuration/ReprocessingConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static ReprocessingConfiguration Load()
8484
/// <returns>The reprocessing configuration.</returns>
8585
public static ReprocessingConfiguration Load(string sectionName)
8686
{
87-
var section = (ConfigurationSection) ConfigurationManager.GetSection(sectionName);
87+
var section = (ConfigurationSection) System.Configuration.ConfigurationManager.GetSection(sectionName);
8888
return GetConfigurationFromSection(section);
8989
}
9090

Extensions/Xtensive.Orm.Security/Configuration/SecurityConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static SecurityConfiguration Load()
8383
/// </returns>
8484
public static SecurityConfiguration Load(string sectionName)
8585
{
86-
var section = (ConfigurationSection) ConfigurationManager.GetSection(sectionName);
86+
var section = (ConfigurationSection) System.Configuration.ConfigurationManager.GetSection(sectionName);
8787
return GetConfigurationFromSection(section);
8888
}
8989

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/PostgreSqlHelper.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ internal static NpgsqlInterval CreateNativeIntervalFromTimeSpan(in TimeSpan time
2121

2222
var days = timeSpan.Days;
2323
var timeTicks = ticks - (days * TimeSpan.TicksPerDay);
24-
#if NET7_0_OR_GREATER
2524
var microseconds = timeTicks / TimeSpan.TicksPerMicrosecond;
26-
#else
27-
var microseconds = timeTicks / 10L; // same as TimeSpan.TicksPerMicrosecond available in .NET7+
28-
#endif
2925
// no months!
3026
return new NpgsqlInterval(0, days, microseconds);
3127
}
@@ -43,11 +39,7 @@ internal static TimeSpan ResurrectTimeSpanFromNpgsqlInterval(in NpgsqlInterval n
4339
: npgsqlInterval.Days;
4440

4541
var ticksOfDays = days * TimeSpan.TicksPerDay;
46-
#if NET7_0_OR_GREATER
4742
var overallTicks = ticksOfDays + (npgsqlInterval.Time * TimeSpan.TicksPerMicrosecond);
48-
#else
49-
var overallTicks = ticksOfDays + (npgsqlInterval.Time * 10); //same as TimeSpan.TicksPerMicrosecond available in .NET7+
50-
#endif
5143
return TimeSpan.FromTicks(overallTicks);
5244
}
5345

@@ -115,18 +107,7 @@ public static TimeZoneInfo GetTimeZoneInfoForServerTimeZone(string connectionTim
115107

116108
private static bool TryFindSystemTimeZoneById(string id, out TimeZoneInfo timeZoneInfo)
117109
{
118-
#if NET8_0_OR_GREATER
119110
return TimeZoneInfo.TryFindSystemTimeZoneById(id, out timeZoneInfo);
120-
#else
121-
try {
122-
timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(id);
123-
return true;
124-
}
125-
catch {
126-
timeZoneInfo = null;
127-
return false;
128-
}
129-
#endif
130111
}
131112
}
132113
}

Orm/Xtensive.Orm.Tests.Core/DotNetFramework/AllocationTest.cs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ private void TestClassAllocation(double speedFactor)
9292
// Warmup
9393
int iterations = 100;
9494
AllocateClass_SlimObject(iterations);
95-
#if !NET8_0_OR_GREATER
96-
AllocateClass_SlimObject_ByFormatterServices(iterations);
97-
#endif
9895
AllocateClass_FinalizableSlimObject(iterations);
9996
AllocateClass_InheritedObject3(iterations);
10097
AllocateClass<SlimObject>(iterations);
@@ -112,11 +109,6 @@ private void TestClassAllocation(double speedFactor)
112109
using (new Measurement("SlimObject", MeasurementOptions.Log, iterations))
113110
AllocateClass_SlimObject(iterations);
114111
TestHelper.CollectGarbage();
115-
#if !NET8_0_OR_GREATER
116-
using (new Measurement("SlimObject (using FormatterServices)", MeasurementOptions.Log, iterations))
117-
AllocateClass_SlimObject_ByFormatterServices(iterations);
118-
#endif
119-
TestHelper.CollectGarbage();
120112
using (new Measurement("FinalizableSlimObject", MeasurementOptions.Log, iterations))
121113
AllocateClass_FinalizableSlimObject(iterations);
122114
TestHelper.CollectGarbage();
@@ -213,25 +205,6 @@ private void AllocateClass_InheritedObject3(int iterationCount)
213205
new InheritedObject3();
214206
}
215207
}
216-
#if !NET8_0_OR_GREATER
217-
218-
private void AllocateClass_SlimObject_ByFormatterServices(int iterationCount)
219-
{
220-
var type = typeof(SlimObject);
221-
for (int i = 0; i<iterationCount; i+=10) {
222-
FormatterServices.GetUninitializedObject(type);
223-
FormatterServices.GetUninitializedObject(type);
224-
FormatterServices.GetUninitializedObject(type);
225-
FormatterServices.GetUninitializedObject(type);
226-
FormatterServices.GetUninitializedObject(type);
227-
FormatterServices.GetUninitializedObject(type);
228-
FormatterServices.GetUninitializedObject(type);
229-
FormatterServices.GetUninitializedObject(type);
230-
FormatterServices.GetUninitializedObject(type);
231-
FormatterServices.GetUninitializedObject(type);
232-
}
233-
}
234-
#endif
235208

236209
private void AllocateClass_FinalizableSlimObject(int iterationCount)
237210
{

Orm/Xtensive.Orm.Tests.Sql/PostgreSql/PostgreSqlHelperTest.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,7 @@ private static void LoadServerTimeZones(Xtensive.Sql.SqlConnection connection,
176176

177177
private static bool TryFindSystemTimeZoneById(string id, out TimeZoneInfo timeZoneInfo)
178178
{
179-
#if NET8_0_OR_GREATER
180179
return TimeZoneInfo.TryFindSystemTimeZoneById(id, out timeZoneInfo);
181-
#else
182-
try {
183-
timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(id);
184-
return true;
185-
}
186-
catch {
187-
timeZoneInfo = null;
188-
return false;
189-
}
190-
#endif
191180
}
192181
}
193182
}

Orm/Xtensive.Orm/Core/Exceptions/AggregateException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public override string ToString()
6161
.AppendFormat("{0}:", Strings.OriginalExceptions);
6262
int i = 1;
6363
foreach (Exception exception in exceptions)
64-
sb.AppendLine().AppendFormat("{0}: {1}", i++, exception);
64+
_ = sb.AppendLine().AppendFormat("{0}: {1}", i++, exception);
6565
return sb.ToString();
6666
}
6767

Orm/Xtensive.Orm/Core/Internals/ValueStringBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ public void Insert(int index, string? s)
102102

103103
var remaining = position - index;
104104
chars.Slice(index, remaining).CopyTo(chars.Slice(index + count));
105-
#if NET6_0_OR_GREATE
106105
s.CopyTo(chars.Slice(index));
107-
#else
108-
s.AsSpan().CopyTo(chars.Slice(index));
109-
#endif
110106
position += count;
111107
}
112108

Orm/Xtensive.Orm/IoC/ServiceContainer.cs

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,37 +29,24 @@ public class ServiceContainer : ServiceContainerBase
2929
{
3030
private static readonly Type iServiceContainerType = typeof(IServiceContainer);
3131

32-
#if NET8_0_OR_GREATER
3332
private static readonly Func<ServiceRegistration, Pair<ConstructorInvoker, ParameterInfo[]>> ConstructorFactory = serviceInfo => {
34-
#else
35-
private static readonly Func<ServiceRegistration, Pair<ConstructorInfo, ParameterInfo[]>> ConstructorFactory = serviceInfo => {
36-
#endif
3733
var mappedType = serviceInfo.MappedType;
3834
var ctor = (
3935
from c in mappedType.GetConstructors()
4036
where c.GetAttribute<ServiceConstructorAttribute>(AttributeSearchOptions.InheritNone) != null
4137
select c
4238
).SingleOrDefault() ?? mappedType.GetConstructor(Array.Empty<Type>());
4339
var @params = ctor?.GetParameters();
44-
#if NET8_0_OR_GREATER
4540
return new(ctor is null ? null : ConstructorInvoker.Create(ctor), @params);
46-
#else
47-
return new(ctor, @params);
48-
#endif
4941
};
5042

5143
private readonly IReadOnlyDictionary<Key, List<ServiceRegistration>> types;
5244

53-
private readonly ConcurrentDictionary<ServiceRegistration, Lazy<object>> instances =
54-
new ConcurrentDictionary<ServiceRegistration, Lazy<object>>();
45+
private readonly ConcurrentDictionary<ServiceRegistration, Lazy<object>> instances = new();
5546

56-
#if NET8_0_OR_GREATER
5747
private readonly ConcurrentDictionary<ServiceRegistration, Pair<ConstructorInvoker, ParameterInfo[]>> constructorCache = new();
58-
#else
59-
private readonly ConcurrentDictionary<ServiceRegistration, Pair<ConstructorInfo, ParameterInfo[]>> constructorCache = new();
60-
#endif
6148

62-
private readonly ConcurrentDictionary<(Type, int), bool> creating = new ConcurrentDictionary<(Type, int), bool>();
49+
private readonly ConcurrentDictionary<(Type, int), bool> creating = new();
6350

6451
#region Protected virtual methods (to override)
6552

@@ -118,14 +105,10 @@ protected virtual object CreateInstance(ServiceRegistration serviceInfo)
118105
finally {
119106
_ = creating.TryRemove(key, out _);
120107
}
121-
#if NET8_0_OR_GREATER
122108
return cInfo.Invoke(args.AsSpan());
123-
#else
124-
return cInfo.Invoke(args);
125-
#endif
126109
}
127110

128-
#endregion
111+
#endregion
129112

130113
#region Private \ internal methods
131114

@@ -210,28 +193,15 @@ public static IServiceContainer Create(Type containerType, object configuration,
210193
Type configurationType = configuration?.GetType(),
211194
parentType = parent?.GetType();
212195
return (IServiceContainer) (
213-
#if NET8_0_OR_GREATER
214196
FindConstructorInvoker(containerType, configurationType, parentType)?.Invoke(configuration, parent)
215197
?? FindConstructorInvoker(containerType, configurationType)?.Invoke(configuration)
216198
?? FindConstructorInvoker(containerType, parentType)?.Invoke(parent)
217-
#else
218-
FindConstructor(containerType, configurationType, parentType)?.Invoke(new[] { configuration, parent })
219-
?? FindConstructor(containerType, configurationType)?.Invoke(new[] { configuration })
220-
?? FindConstructor(containerType, parentType)?.Invoke(new[] { parent })
221-
#endif
222199
?? throw new ArgumentException(Strings.ExContainerTypeDoesNotProvideASuitableConstructor, "containerType")
223200
);
224201
}
225202

226-
#if NET8_0_OR_GREATER
227203
private static ConstructorInvoker FindConstructorInvoker(Type containerType, params Type[] argumentTypes) =>
228204
containerType.GetSingleConstructorInvokerOrDefault(argumentTypes);
229-
#else
230-
#pragma warning disable CS0612 // Type or member is obsolete
231-
private static ConstructorInfo FindConstructor(Type containerType, params Type[] argumentTypes) =>
232-
containerType.GetSingleConstructorOrDefault(argumentTypes);
233-
#pragma warning restore CS0612 // Type or member is obsolete
234-
#endif
235205

236206
#endregion
237207

@@ -304,7 +274,7 @@ public static IServiceContainer Create(ConfigurationSection section, string name
304274
var typeRegistry = new TypeRegistry(new ServiceTypeRegistrationProcessor());
305275

306276
foreach (var typeRegistrationElement in configuration.Auto)
307-
typeRegistry.Register(typeRegistrationElement.ToNative());
277+
_ = typeRegistry.Register(typeRegistrationElement.ToNative());
308278
foreach (var type in typeRegistry)
309279
registrations.AddRange(ServiceRegistration.CreateAll(type));
310280
foreach (var serviceRegistrationElement in configuration.Explicit)
@@ -347,7 +317,7 @@ public override void Dispose()
347317
using (var toDispose = new DisposableSet()) {
348318
foreach (var lazy in instances.Values) {
349319
if (lazy.IsValueCreated && lazy.Value is IDisposable disposable) {
350-
toDispose.Add(disposable);
320+
_ = toDispose.Add(disposable);
351321
}
352322
}
353323
}

0 commit comments

Comments
 (0)