Skip to content

Commit

Permalink
Fix AnchorNotFoundException when another exception occurs during dese…
Browse files Browse the repository at this point in the history
…rialization.
  • Loading branch information
aaubry committed Jul 3, 2014
1 parent 5b1647c commit 710d71c
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ release/*
packages
packages/*
!packages/repositories.config

README.html
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ The most up-to-date version can always be found in the following NuGet packages:

# Changelog

## Version 3.2.1

* Fix AnchorNotFoundException when another exception occurs during deserialization.

## Version 3.2.0

This release adds merge key support: http://yaml.org/type/merge.html

Example from BackreferencesAreMergedWithMappings unit test:

```C#
var reader = new EventReader(new MergingParser(new Parser(stream)));
var result = Deserializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(parser);
```

## Version 3.1.1

This is a bugfix release that fixes issue #90.

## Version 3.1.0

* Add a parameter to the deserializer to ignore unmapped properties in YAML.
Expand Down
2 changes: 1 addition & 1 deletion YamlDotNet.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- This build file requires .NET 4.0 and nant 0.91 alpha 2 or higher -->
<property name="nant.settings.currentframework" value="net-4.0"/>

<property name="version" value="3.2.0" />
<property name="version" value="3.2.1" />

<fileset id="binaries">
<include name="YamlDotNet/bin/Release/YamlDotNet.dll" />
Expand Down
59 changes: 31 additions & 28 deletions YamlDotNet.sln
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{69EE9636-55BA-49C2-827E-D5684221C345}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
CommonAssemblyInfo.cs = CommonAssemblyInfo.cs
enforce-formatting-rules.sh = enforce-formatting-rules.sh
LICENSE = LICENSE
license.cs = license.cs
README.md = README.md
YamlDotNet.build = YamlDotNet.build
YamlDotNet.Dynamic.nuspec = YamlDotNet.Dynamic.nuspec
YamlDotNet.FxCop = YamlDotNet.FxCop
Expand Down Expand Up @@ -55,14 +58,14 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0FB497EA-A116-406A-AE8C-A24933D8CB21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FB497EA-A116-406A-AE8C-A24933D8CB21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FB497EA-A116-406A-AE8C-A24933D8CB21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FB497EA-A116-406A-AE8C-A24933D8CB21}.Release|Any CPU.Build.0 = Release|Any CPU
{1EC10966-19C0-4CE3-949E-D11F600B8CA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EC10966-19C0-4CE3-949E-D11F600B8CA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EC10966-19C0-4CE3-949E-D11F600B8CA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EC10966-19C0-4CE3-949E-D11F600B8CA3}.Release|Any CPU.Build.0 = Release|Any CPU
{708C56D8-492C-4EED-A306-1FE75FC7D234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{708C56D8-492C-4EED-A306-1FE75FC7D234}.Debug|Any CPU.Build.0 = Debug|Any CPU
{708C56D8-492C-4EED-A306-1FE75FC7D234}.Release|Any CPU.ActiveCfg = Release|Any CPU
{708C56D8-492C-4EED-A306-1FE75FC7D234}.Release|Any CPU.Build.0 = Release|Any CPU
{57B52D79-04A0-4091-8EE2-B419C009C2A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57B52D79-04A0-4091-8EE2-B419C009C2A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57B52D79-04A0-4091-8EE2-B419C009C2A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -71,38 +74,41 @@ Global
{6E3BEF5A-2DBA-4941-972D-BD6AF27B4A71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E3BEF5A-2DBA-4941-972D-BD6AF27B4A71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E3BEF5A-2DBA-4941-972D-BD6AF27B4A71}.Release|Any CPU.Build.0 = Release|Any CPU
{708C56D8-492C-4EED-A306-1FE75FC7D234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{708C56D8-492C-4EED-A306-1FE75FC7D234}.Debug|Any CPU.Build.0 = Debug|Any CPU
{708C56D8-492C-4EED-A306-1FE75FC7D234}.Release|Any CPU.ActiveCfg = Release|Any CPU
{708C56D8-492C-4EED-A306-1FE75FC7D234}.Release|Any CPU.Build.0 = Release|Any CPU
{BF32DE1B-6276-4341-B212-F8862ADBBA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF32DE1B-6276-4341-B212-F8862ADBBA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF32DE1B-6276-4341-B212-F8862ADBBA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF32DE1B-6276-4341-B212-F8862ADBBA7A}.Release|Any CPU.Build.0 = Release|Any CPU
{A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Release|Any CPU.Build.0 = Release|Any CPU
{773B71D6-FEE5-4E4D-8717-5C5EF58D6F17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{773B71D6-FEE5-4E4D-8717-5C5EF58D6F17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{773B71D6-FEE5-4E4D-8717-5C5EF58D6F17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{773B71D6-FEE5-4E4D-8717-5C5EF58D6F17}.Release|Any CPU.Build.0 = Release|Any CPU
{91A1F4BC-65C0-42E6-B5FD-320A2D59AF71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91A1F4BC-65C0-42E6-B5FD-320A2D59AF71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A1F4BC-65C0-42E6-B5FD-320A2D59AF71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A1F4BC-65C0-42E6-B5FD-320A2D59AF71}.Release|Any CPU.Build.0 = Release|Any CPU
{A5C7D77C-0F08-4647-8376-3719BD6DEBD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5C7D77C-0F08-4647-8376-3719BD6DEBD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5C7D77C-0F08-4647-8376-3719BD6DEBD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5C7D77C-0F08-4647-8376-3719BD6DEBD9}.Release|Any CPU.Build.0 = Release|Any CPU
{A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Release|Any CPU.Build.0 = Release|Any CPU
{BE49A287-5F47-4E3B-90EB-97B51451934C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE49A287-5F47-4E3B-90EB-97B51451934C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE49A287-5F47-4E3B-90EB-97B51451934C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE49A287-5F47-4E3B-90EB-97B51451934C}.Release|Any CPU.Build.0 = Release|Any CPU
{BF32DE1B-6276-4341-B212-F8862ADBBA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF32DE1B-6276-4341-B212-F8862ADBBA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF32DE1B-6276-4341-B212-F8862ADBBA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF32DE1B-6276-4341-B212-F8862ADBBA7A}.Release|Any CPU.Build.0 = Release|Any CPU
{0FB497EA-A116-406A-AE8C-A24933D8CB21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FB497EA-A116-406A-AE8C-A24933D8CB21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FB497EA-A116-406A-AE8C-A24933D8CB21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FB497EA-A116-406A-AE8C-A24933D8CB21}.Release|Any CPU.Build.0 = Release|Any CPU
{C6E0B465-8422-4D6B-85CE-C59724A28E1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6E0B465-8422-4D6B-85CE-C59724A28E1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6E0B465-8422-4D6B-85CE-C59724A28E1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6E0B465-8422-4D6B-85CE-C59724A28E1F}.Release|Any CPU.Build.0 = Release|Any CPU
{BE49A287-5F47-4E3B-90EB-97B51451934C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BE49A287-5F47-4E3B-90EB-97B51451934C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BE49A287-5F47-4E3B-90EB-97B51451934C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BE49A287-5F47-4E3B-90EB-97B51451934C}.Release|Any CPU.Build.0 = Release|Any CPU
{91A1F4BC-65C0-42E6-B5FD-320A2D59AF71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91A1F4BC-65C0-42E6-B5FD-320A2D59AF71}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A1F4BC-65C0-42E6-B5FD-320A2D59AF71}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A1F4BC-65C0-42E6-B5FD-320A2D59AF71}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{773B71D6-FEE5-4E4D-8717-5C5EF58D6F17} = {FFEB1B4B-D432-4268-B690-CD16598807CA}
Expand All @@ -115,7 +121,4 @@ Global
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = PerformanceTests\YamlDotNet.PerformanceTests.Runner\YamlDotNet.PerformanceTests.Runner.csproj
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions YamlDotNet/Serialization/Deserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public object Deserialize(EventReader reader, Type type)
using (var state = new SerializerState())
{
result = valueDeserializer.DeserializeValue(reader, type, state, valueDeserializer);
state.OnDeserialization();
}
}

Expand Down
12 changes: 12 additions & 0 deletions YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

namespace YamlDotNet.Serialization.Utilities
{
/// <summary>
/// Indicates that a class used as deserialization state
/// needs to be notified after deserialization.
/// </summary>
public interface IPostDeserializationCallback
{
void OnDeserialization();
}
}
12 changes: 12 additions & 0 deletions YamlDotNet/Serialization/Utilities/SerializerState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ public T Get<T>()
return (T)value;
}

/// <summary>
/// Invokes <see cref="IPostDeserializationCallback.OnDeserialization" /> on all
/// objects added to this collection that implement <see cref="IPostDeserializationCallback" />.
/// </summary>
public void OnDeserialization()
{
foreach (var callback in items.Values.OfType<IPostDeserializationCallback>())
{
callback.OnDeserialization();
}
}

public void Dispose()
{
foreach (var disposable in items.Values.OfType<IDisposable>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public AliasValueDeserializer(IValueDeserializer innerDeserializer)
this.innerDeserializer = innerDeserializer;
}

private sealed class AliasState : Dictionary<string, ValuePromise>, IDisposable
private sealed class AliasState : Dictionary<string, ValuePromise>, IPostDeserializationCallback
{
public void Dispose()
public void OnDeserialization()
{
foreach (var promise in Values)
{
Expand Down
1 change: 1 addition & 0 deletions YamlDotNet/YamlDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
<Compile Include="Serialization\TypeInspectors\TypeInspectorSkeleton.cs" />
<Compile Include="Serialization\TypeResolvers\DynamicTypeResolver.cs" />
<Compile Include="Serialization\TypeResolvers\StaticTypeResolver.cs" />
<Compile Include="Serialization\Utilities\IPostDeserializationCallback.cs" />
<Compile Include="Serialization\Utilities\ObjectAnchorCollection.cs" />
<Compile Include="Serialization\Utilities\ReflectionUtility.cs" />
<Compile Include="Serialization\Utilities\SerializerState.cs" />
Expand Down

0 comments on commit 710d71c

Please sign in to comment.