Skip to content

Commit

Permalink
Replace System.Runtime.Serialization GetUninitializedObject method
Browse files Browse the repository at this point in the history
Replaces obsolete `System.Runtime.Serialization` `FormatterServices.GetUninitializedObject` reference in MappingTests with equivalent version in System.Runtime.CompilerServices
  • Loading branch information
max-lancaster authored and jasontaylordev committed Feb 15, 2024
1 parent 21998c4 commit 18b1123
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions tests/Application.UnitTests/Common/Mappings/MappingTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.CompilerServices;
using AutoMapper;
using CleanArchitecture.Application.Common.Interfaces;
using CleanArchitecture.Application.Common.Models;
Expand Down Expand Up @@ -48,9 +48,6 @@ private object GetInstanceOf(Type type)
return Activator.CreateInstance(type)!;

// Type without parameterless constructor
// TODO: Figure out an alternative approach to the now obsolete `FormatterServices.GetUninitializedObject` method.
#pragma warning disable SYSLIB0050 // Type or member is obsolete
return FormatterServices.GetUninitializedObject(type);
#pragma warning restore SYSLIB0050 // Type or member is obsolete
return RuntimeHelpers.GetUninitializedObject(type);
}
}

0 comments on commit 18b1123

Please sign in to comment.