UnitTests/BinarySerialisationVersioningTests.cs
/// <summary>
/// If an older version of a type is serialised and then deserialised when a newer version of that type is loaded, if the newer version has any fields that do not
/// have data in the serialised data then deserialisation should fail. Otherwise, if there was an immutable type that is normally initialised via a constructor that
/// sets all properties to non-null properties them consumers of that type may reasonably expect all of the properties to be non-null but this would not be the case
/// if deserialising from data that does not have information for some of those fields.
/// </summary>
If an older version of a type is serialised and then deserialised when a newer version of that type is loaded, if the newer version has any fields that do not
have data in the serialised data then deserialisation should fail. Otherwise, if there was an immutable type that is normally initialised via a constructor that
sets all properties to non-null properties them consumers of that type may reasonably expect all of the properties to be non-null but this would not be the case
if deserialising from data that does not have information for some of those fields.
If an older version of a type is serialised and then deserialised when a newer version of that type is loaded if the newer version has any fields that do not have data in the serialised data then deserialisation should fail . Otherwise if there was an immutable type that is normally initialised via a constructor that sets all properties to non - null properties them consumers of that type may reasonably expect all of the properties to be non - null but this would not be the case if deserialising from data that does not have information for some of those fields .
[Fact]
		public static void DeserialisationWillFailIfAnyFieldsHaveNoData()
		{
			var sourceType = ConstructType(GetModuleBuilder("DynamicAssemblyFor" + GetMyName(), new Version(1, 0)), "MyClass", new Tuple<string, Type>[0]);
			var instance = Activator.CreateInstance(sourceType);
			var serialisedData = BinarySerialisation.Serialise(instance);
			var destinationType = ConstructType(
				GetModuleBuilder("DynamicAssemblyFor" + GetMyName(), new Version(1, 0)),
				"MyClass",
				new[] { Tuple.Create("Id", typeof(int)) }
			);
			Assert.Throws<FieldNotPresentInSerialisedDataException>(() =>
				ResolveDynamicAssembliesWhilePerformingAction(
					() => Deserialise(serialisedData, destinationType),
					destinationType
				)
			);
		}
[ Fact ] public static void DeserialisationWillFailIfAnyFieldsHaveNoData ( ) { var sourceType = ConstructType ( GetModuleBuilder ( " " + GetMyName ( ) , new Version ( 1 , 0 ) ) , " " , new Tuple < string , Type > [ 0 ] ) ; var instance = Activator . CreateInstance ( sourceType ) ; var serialisedData = BinarySerialisation . Serialise ( instance ) ; var destinationType = ConstructType ( GetModuleBuilder ( " " + GetMyName ( ) , new Version ( 1 , 0 ) ) , " " , new [ ] { Tuple . Create ( " " , typeof ( int ) ) } ) ; Assert . Throws < FieldNotPresentInSerialisedDataException > ( ( ) => ResolveDynamicAssembliesWhilePerformingAction ( ( ) => Deserialise ( serialisedData , destinationType ) , destinationType ) ) ; }
If an older version of a type is serialised and then deserialised when a newer version of that type is loaded, if the newer version has any fields that do not
have data in the serialised data then deserialisation should fail.
If an older version of a type is serialised and then deserialised when a newer version of that type is loaded if the newer version has any fields that do not have data in the serialised data then deserialisation should fail .