Skip to content

Commit 92a9ae6

Browse files
committed
CSHARP-1561, CSHARP-1562, CSHARP-1563: Renamed preprocessor symbol NETCORE to NETSTANDARD16.
1 parent 90ef04b commit 92a9ae6

File tree

99 files changed

+218
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+218
-210
lines changed

src/MongoDB.Bson.NetCore/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"compile": {
1616
"include": [ "../MongoDB.Bson/**/*.cs", "../MongoDB.Shared/Hasher.cs" ]
1717
},
18-
"define": [ "DEBUG", "TRACE", "NETCORE" ]
18+
"define": [ "DEBUG", "TRACE", "NETSTANDARD16" ]
1919
}
2020
}
2121
}

src/MongoDB.Bson/IO/BsonReader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ public virtual IByteBuffer ReadRawBsonArray()
276276
bsonWriter.WriteEndDocument();
277277

278278
byte[] memoryStreamBuffer;
279-
#if NET45
280-
memoryStreamBuffer = memoryStream.GetBuffer();
281-
#else
279+
#if NETSTANDARD16
282280
memoryStreamBuffer = memoryStream.ToArray();
281+
#else
282+
memoryStreamBuffer = memoryStream.GetBuffer();
283283
#endif
284284
var buffer = new ByteArrayBuffer(memoryStreamBuffer, (int)memoryStream.Length, isReadOnly: true);
285285
return new ByteBufferSlice(buffer, (int)startPosition, (int)(endPosition - startPosition));

src/MongoDB.Bson/IO/BsonStreamAdapter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ public override ArraySegment<byte> ReadCStringBytes()
296296
if (b == 0)
297297
{
298298
byte[] memoryStreamBuffer;
299-
#if NET45
300-
memoryStreamBuffer = memoryStream.GetBuffer();
301-
#else
299+
#if NETSTANDARD16
302300
memoryStreamBuffer = memoryStream.ToArray();
301+
#else
302+
memoryStreamBuffer = memoryStream.GetBuffer();
303303
#endif
304304
return new ArraySegment<byte>(memoryStreamBuffer, 0, (int)memoryStream.Length);
305305
}

src/MongoDB.Bson/ObjectModel/ObjectId.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,10 @@ public static void Unpack(byte[] bytes, out int timestamp, out int machine, out
377377
// private static methods
378378
private static int GetAppDomainId()
379379
{
380-
#if NET45
381-
return AppDomain.CurrentDomain.Id;
382-
#else
380+
#if NETSTANDARD16
383381
return 1;
382+
#else
383+
return AppDomain.CurrentDomain.Id;
384384
#endif
385385
}
386386

@@ -392,10 +392,10 @@ private static int GetAppDomainId()
392392
[MethodImpl(MethodImplOptions.NoInlining)]
393393
private static int GetCurrentProcessId()
394394
{
395-
#if NET45
396-
return Process.GetCurrentProcess().Id;
397-
#else
395+
#if NETSTANDARD16
398396
return 1;
397+
#else
398+
return Process.GetCurrentProcess().Id;
399399
#endif
400400
}
401401

@@ -408,10 +408,10 @@ private static int GetMachineHash()
408408

409409
private static string GetMachineName()
410410
{
411-
#if NET45
412-
return Environment.MachineName;
413-
#else
411+
#if NETSTANDARD16
414412
return Environment.GetEnvironmentVariable("COMPUTERNAME") ?? "";
413+
#else
414+
return Environment.MachineName;
415415
#endif
416416
}
417417

src/MongoDB.Bson/Serialization/AttributedSerializationProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public override IBsonSerializer GetSerializer(Type type, IBsonSerializerRegistry
3939
throw new ArgumentException(message, "type");
4040
}
4141

42-
#if NET45
43-
var serializerAttributes = typeInfo.GetCustomAttributes(typeof(BsonSerializerAttribute), false); // don't inherit
44-
#else
42+
#if NETSTANDARD16
4543
var serializerAttributes = typeInfo.GetCustomAttributes(typeof(BsonSerializerAttribute), false).ToArray(); // don't inherit
44+
#else
45+
var serializerAttributes = typeInfo.GetCustomAttributes(typeof(BsonSerializerAttribute), false); // don't inherit
4646
#endif
4747
if (serializerAttributes.Length == 1)
4848
{

src/MongoDB.Bson/Serialization/BsonClassMap.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,13 +1268,13 @@ private Func<object> GetCreator()
12681268
}
12691269
else
12701270
{
1271-
#if NET45
1271+
#if NETSTANDARD16
1272+
var message = $"Type '{_classType.GetType().Name}' does not have a default constructor.";
1273+
throw new BsonSerializationException(message);
1274+
#else
12721275
// lambdaExpression = () => FormatterServices.GetUninitializedObject(classType)
12731276
var getUnitializedObjectMethodInfo = typeof(FormatterServices).GetMethod("GetUninitializedObject", BindingFlags.Public | BindingFlags.Static);
12741277
body = Expression.Call(getUnitializedObjectMethodInfo, Expression.Constant(_classType));
1275-
#else
1276-
var message = $"Type '{_classType.GetType().Name}' does not have a default constructor.";
1277-
throw new BsonSerializationException(message);
12781278
#endif
12791279
}
12801280
var lambdaExpression = Expression.Lambda<Func<object>>(body);
@@ -1537,9 +1537,7 @@ public void UnmapProperty<TMember>(Expression<Func<TClass, TMember>> propertyLam
15371537
// private static methods
15381538
private static MethodInfo[] GetPropertyAccessors(PropertyInfo propertyInfo)
15391539
{
1540-
#if NET45
1541-
return propertyInfo.GetAccessors(true);
1542-
#else
1540+
#if NETSTANDARD16
15431541
var accessors = new List<MethodInfo>();
15441542
if (propertyInfo.GetMethod != null)
15451543
{
@@ -1550,6 +1548,8 @@ private static MethodInfo[] GetPropertyAccessors(PropertyInfo propertyInfo)
15501548
accessors.Add(propertyInfo.SetMethod);
15511549
}
15521550
return accessors.ToArray();
1551+
#else
1552+
return propertyInfo.GetAccessors(true);
15531553
#endif
15541554
}
15551555

@@ -1593,7 +1593,7 @@ private static PropertyInfo FindPropertyImplementation(PropertyInfo interfacePro
15931593
{
15941594
var interfaceType = interfacePropertyInfo.DeclaringType;
15951595

1596-
#if NETCORE
1596+
#if NETSTANDARD16
15971597
var actualTypeInfo = actualType.GetTypeInfo();
15981598
var bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
15991599
var actualTypePropertyInfos = actualTypeInfo.GetMembers(bindingFlags).OfType<PropertyInfo>();

src/MongoDB.Bson/Serialization/BsonSerializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,10 @@ internal static void EnsureKnownTypesAreRegistered(Type nominalType)
691691
if (!__typesWithRegisteredKnownTypes.Contains(nominalType))
692692
{
693693
// only call LookupClassMap for classes with a BsonKnownTypesAttribute
694-
#if NET45
695-
var knownTypesAttribute = nominalType.GetTypeInfo().GetCustomAttributes(typeof(BsonKnownTypesAttribute), false);
696-
#else
694+
#if NETSTANDARD16
697695
var knownTypesAttribute = nominalType.GetTypeInfo().GetCustomAttributes(typeof(BsonKnownTypesAttribute), false).ToArray();
696+
#else
697+
var knownTypesAttribute = nominalType.GetTypeInfo().GetCustomAttributes(typeof(BsonKnownTypesAttribute), false);
698698
#endif
699699
if (knownTypesAttribute != null && knownTypesAttribute.Length > 0)
700700
{

src/MongoDB.Bson/Serialization/IdGenerators/AscendingGuidGenerator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ public bool IsEmpty(object id)
141141
[MethodImpl(MethodImplOptions.NoInlining)]
142142
private static int GetCurrentProcessId()
143143
{
144-
#if NET45
145-
return Process.GetCurrentProcess().Id;
146-
#else
144+
#if NETSTANDARD16
147145
return 1;
146+
#else
147+
return Process.GetCurrentProcess().Id;
148148
#endif
149149
}
150150

@@ -158,10 +158,10 @@ private static byte[] GetMachineHash()
158158

159159
private static string GetMachineName()
160160
{
161-
#if NET45
162-
return Environment.MachineName;
163-
#else
161+
#if NETSTANDARD16
164162
return Environment.GetEnvironmentVariable("COMPUTERNAME") ?? "";
163+
#else
164+
return Environment.MachineName;
165165
#endif
166166
}
167167
}

src/MongoDB.Bson/Serialization/Serializers/CultureInfoSerializer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ protected override CultureInfo DeserializeValue(BsonDeserializationContext conte
7373
case Flags.UseUserOverride: useUserOverride = _booleanSerializer.Deserialize(context); break;
7474
}
7575
});
76-
#if NET45
77-
return new CultureInfo(name, useUserOverride);
78-
#else
76+
#if NETSTANDARD16
7977
if (!useUserOverride)
8078
{
8179
throw new FormatException("CultureInfo does not support useUserOverride on this version of the .NET Framework.");
8280
}
8381
return new CultureInfo(name);
82+
#else
83+
return new CultureInfo(name, useUserOverride);
8484
#endif
8585

8686
case BsonType.String:
@@ -101,10 +101,10 @@ protected override void SerializeValue(BsonSerializationContext context, BsonSer
101101
{
102102
var bsonWriter = context.Writer;
103103

104-
#if NET45
105-
var useUserOverride = value.UseUserOverride;
106-
#else
104+
#if NETSTANDARD16
107105
var useUserOverride = true;
106+
#else
107+
var useUserOverride = value.UseUserOverride;
108108
#endif
109109

110110
if (useUserOverride)

src/MongoDB.Driver.Core.NetCore/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"compile": {
2020
"include": [ "../MongoDB.Driver.Core/**/*.cs", "../MongoDB.Shared/Hasher.cs" ]
2121
},
22-
"define": [ "DEBUG", "TRACE", "NETCORE" ]
22+
"define": [ "DEBUG", "TRACE", "NETSTANDARD16" ]
2323
}
2424
}
2525
}

0 commit comments

Comments
 (0)