Minor: `LineMapping` and `MappingLocation` debug visualizations were types' full names
- add `ToString()` overrides for these classes Nits: - improve assertion failures about code mapping mismatches - add `GENERATE_BASELINES` reminder to test project.json
This commit is contained in:
parent
26afdbd889
commit
7b8126367c
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Razor.Generator.Compiler
|
namespace Microsoft.AspNet.Razor.Generator.Compiler
|
||||||
{
|
{
|
||||||
public class LineMapping
|
public class LineMapping
|
||||||
|
|
@ -40,5 +42,10 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
|
||||||
{
|
{
|
||||||
return !left.Equals(right);
|
return !left.Equals(right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format(CultureInfo.CurrentUICulture, "{0} -> {1}", DocumentLocation, GeneratedLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Globalization;
|
||||||
using Microsoft.AspNet.Razor.Text;
|
using Microsoft.AspNet.Razor.Text;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Razor.Generator.Compiler
|
namespace Microsoft.AspNet.Razor.Generator.Compiler
|
||||||
|
|
@ -37,6 +38,16 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler
|
||||||
return base.GetHashCode();
|
return base.GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
CultureInfo.CurrentCulture, "({0}:{1},{2} [{3}])",
|
||||||
|
AbsoluteIndex,
|
||||||
|
LineIndex,
|
||||||
|
CharacterIndex,
|
||||||
|
ContentLength);
|
||||||
|
}
|
||||||
|
|
||||||
public static bool operator ==(MappingLocation left, MappingLocation right)
|
public static bool operator ==(MappingLocation left, MappingLocation right)
|
||||||
{
|
{
|
||||||
return left.Equals(right);
|
return left.Equals(right);
|
||||||
|
|
|
||||||
|
|
@ -181,17 +181,13 @@ namespace Microsoft.AspNet.Razor.Test.Generator
|
||||||
|
|
||||||
if (expectedDesignTimePragmas != null)
|
if (expectedDesignTimePragmas != null)
|
||||||
{
|
{
|
||||||
Assert.True(results.DesignTimeLineMappings != null && results.DesignTimeLineMappings.Count > 0);
|
Assert.True(results.DesignTimeLineMappings != null); // Guard
|
||||||
|
for (var i = 0; i < expectedDesignTimePragmas.Count && i < results.DesignTimeLineMappings.Count; i++)
|
||||||
|
{
|
||||||
|
Assert.Equal(expectedDesignTimePragmas[i], results.DesignTimeLineMappings[i]);
|
||||||
|
}
|
||||||
|
|
||||||
Assert.Equal(expectedDesignTimePragmas.Count, results.DesignTimeLineMappings.Count);
|
Assert.Equal(expectedDesignTimePragmas.Count, results.DesignTimeLineMappings.Count);
|
||||||
|
|
||||||
for (var i = 0; i < expectedDesignTimePragmas.Count; i++)
|
|
||||||
{
|
|
||||||
if (!expectedDesignTimePragmas[i].Equals(results.DesignTimeLineMappings[i]))
|
|
||||||
{
|
|
||||||
Assert.True(false, String.Format("Line mapping {0} is not equivalent.", i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,8 @@
|
||||||
"System.Reflection.TypeExtensions": "4.0.0-beta-*"
|
"System.Reflection.TypeExtensions": "4.0.0-beta-*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"compilationOptions": {
|
||||||
|
"define": [ "__RemoveThisBitTo__GENERATE_BASELINES" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue