Skip to content

Commit

Permalink
Removed "Pa" prefix where is not necessary (#654)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Petrochuk (from Dev Box) <[email protected]>
  • Loading branch information
petrochuk and anpetroc authored May 16, 2024
1 parent 7faaadc commit 867f193
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace Persistence.Tests.PaYaml.Serialization;
[TestClass]
public class NamedObjectSequenceSerializationTests : SerializationTestBase
{
protected override void ConfigureYamlDotNetDeserializer(DeserializerBuilder builder, PaYamlSerializerOptions options, PaSerializationContext serializationContext)
protected override void ConfigureYamlDotNetDeserializer(DeserializerBuilder builder, PaYamlSerializerOptions options, SerializationContext serializationContext)
{
base.ConfigureYamlDotNetDeserializer(builder, options, serializationContext);
builder.WithTypeConverter(new NamedObjectYamlConverter<string>(serializationContext));
}

protected override void ConfigureYamlDotNetSerializer(SerializerBuilder builder, PaYamlSerializerOptions options, PaSerializationContext serializationContext)
protected override void ConfigureYamlDotNetSerializer(SerializerBuilder builder, PaYamlSerializerOptions options, SerializationContext serializationContext)
{
base.ConfigureYamlDotNetSerializer(builder, options, serializationContext);
builder.WithTypeConverter(new NamedObjectYamlConverter<string>(serializationContext));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public PFxExpressionYamlConverterTests()
};
}

protected override void ConfigureYamlDotNetDeserializer(DeserializerBuilder builder, PaYamlSerializerOptions options, PaSerializationContext serializationContext)
protected override void ConfigureYamlDotNetDeserializer(DeserializerBuilder builder, PaYamlSerializerOptions options, SerializationContext serializationContext)
{
base.ConfigureYamlDotNetDeserializer(builder, options, serializationContext);
builder.WithTypeConverter(new PFxExpressionYamlConverter(options.PFxExpressionYamlFormatting));
}

protected override void ConfigureYamlDotNetSerializer(SerializerBuilder builder, PaYamlSerializerOptions options, PaSerializationContext serializationContext)
protected override void ConfigureYamlDotNetSerializer(SerializerBuilder builder, PaYamlSerializerOptions options, SerializationContext serializationContext)
{
base.ConfigureYamlDotNetSerializer(builder, options, serializationContext);
builder.WithTypeConverter(new PFxExpressionYamlConverter(options.PFxExpressionYamlFormatting));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class PaYamlSerializerTests : VSTestBase
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/App.pa.yaml", 5)]
public void DeserializeExamplePaYamlApp(string path, int expectedAppPropertiesCount)
{
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
var paFileRoot = YamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
paFileRoot.ShouldNotBeNull();

// Top level properties
Expand All @@ -34,7 +34,7 @@ public void DeserializeExamplePaYamlApp(string path, int expectedAppPropertiesCo
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Screens/ComponentsScreen4.pa.yaml", 0, 6, 6, 0, 0)]
public void DeserializeExamplePaYamlScreen(string path, int expectedScreenPropertiesCount, int expectedScreenChildrenCount, int expectedDescendantsCount, int expectedScreenGroupsCount, int expectedTotalGroupsCount)
{
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
var paFileRoot = YamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
paFileRoot.ShouldNotBeNull();

// Top level properties
Expand All @@ -57,7 +57,7 @@ public void DeserializeExamplePaYamlScreen(string path, int expectedScreenProper
[DataRow(@"_TestData/SchemaV3_0/Examples/Src/Components/MyHeaderComponent.pa.yaml", 9, 6, 1)]
public void DeserializeExamplePaYamlComponentDefinition(string path, int expectedCustomPropertiesCount, int expectedPropertiesCount, int expectedChildrenCount)
{
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
var paFileRoot = YamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
paFileRoot.ShouldNotBeNull();

// Top level properties
Expand All @@ -77,7 +77,7 @@ public void DeserializeExamplePaYamlComponentDefinition(string path, int expecte
public void DeserializeExamplePaYamlSingleFileApp()
{
var path = @"_TestData/SchemaV3_0/Examples/Single-File-App.pa.yaml";
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
var paFileRoot = YamlSerializer.Deserialize<PaModule>(File.ReadAllText(path));
paFileRoot.ShouldNotBeNull();

// Top level properties
Expand Down Expand Up @@ -112,10 +112,10 @@ public void DeserializeExamplePaYamlSingleFileApp()
public void RoundTripFromYaml(string path)
{
var originalYaml = File.ReadAllText(path);
var paFileRoot = PaYamlSerializer.Deserialize<PaModule>(originalYaml);
var paFileRoot = YamlSerializer.Deserialize<PaModule>(originalYaml);
paFileRoot.ShouldNotBeNull();

var roundTrippedYaml = PaYamlSerializer.Serialize(paFileRoot);
var roundTrippedYaml = YamlSerializer.Serialize(paFileRoot);
TestContext.WriteTextWithLineNumbers(roundTrippedYaml, "roundTrippedYaml:");
roundTrippedYaml.Should().BeYamlEquivalentTo(originalYaml);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization;
Expand All @@ -15,7 +15,7 @@ protected string SerializeViaYamlDotNet<T>(T? testObject, PaYamlSerializerOption
{
options ??= DefaultOptions;

using var serializationContext = new PaSerializationContext();
using var serializationContext = new SerializationContext();
var builder = new SerializerBuilder();
ConfigureYamlDotNetSerializer(builder, options, serializationContext);
serializationContext.ValueSerializer = builder.BuildValueSerializer();
Expand All @@ -24,7 +24,7 @@ protected string SerializeViaYamlDotNet<T>(T? testObject, PaYamlSerializerOption
return serializer.Serialize(testObject);
}

protected virtual void ConfigureYamlDotNetSerializer(SerializerBuilder builder, PaYamlSerializerOptions options, PaSerializationContext serializationContext)
protected virtual void ConfigureYamlDotNetSerializer(SerializerBuilder builder, PaYamlSerializerOptions options, SerializationContext serializationContext)
{
DefaultOptions.TESTONLY_ApplySerializerFormatting(builder);
}
Expand All @@ -34,7 +34,7 @@ protected virtual void ConfigureYamlDotNetSerializer(SerializerBuilder builder,
{
options ??= DefaultOptions;

using var serializationContext = new PaSerializationContext();
using var serializationContext = new SerializationContext();
var builder = new DeserializerBuilder();
ConfigureYamlDotNetDeserializer(builder, options, serializationContext);
serializationContext.ValueDeserializer = builder.BuildValueDeserializer();
Expand All @@ -45,11 +45,11 @@ protected virtual void ConfigureYamlDotNetSerializer(SerializerBuilder builder,
return value;
}

protected virtual void ConfigureYamlDotNetDeserializer(DeserializerBuilder builder, PaYamlSerializerOptions options, PaSerializationContext serializationContext)
protected virtual void ConfigureYamlDotNetDeserializer(DeserializerBuilder builder, PaYamlSerializerOptions options, SerializationContext serializationContext)
{
// This should usually sync up with the default configuration in PaYamlSerializerOptions.ApplyToDeserializerBuilder but without type converters
builder
.WithDuplicateKeyChecking()
;
}
}
}
2 changes: 1 addition & 1 deletion src/Persistence/PaYaml/Models/INamedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public interface INamedObject<TName, TValue>
{
TName Name { get; }
TValue Value { get; }
PaYamlLocation? Start { get; }
YamlLocation? Start { get; }
}
2 changes: 1 addition & 1 deletion src/Persistence/PaYaml/Models/NamedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public record NamedObject<TName, TValue>(TName Name, TValue Value) : INamedObjec
where TName : notnull
where TValue : notnull
{
public PaYamlLocation? Start { get; init; }
public YamlLocation? Start { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Models;

public record PaYamlLocation(int Line, int Column)
public record YamlLocation(int Line, int Column)
{
internal static PaYamlLocation? FromMark(Mark mark)
internal static YamlLocation? FromMark(Mark mark)
{
if (mark.Equals(Mark.Empty))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization;
public class NamedObjectYamlConverter<TValue> : YamlConverter<NamedObject<TValue>>
where TValue : notnull
{
public NamedObjectYamlConverter(PaSerializationContext serializationContext)
public NamedObjectYamlConverter(SerializationContext serializationContext)
: base(serializationContext)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization;

public class PaSerializationContext : IDisposable
public class SerializationContext : IDisposable
{
private readonly SerializerState _serializerState = new();
private bool _isDisposed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public record PaYamlSerializerOptions

public Action<SerializerBuilder>? AdditionalSerializerConfiguration { get; init; }

internal void ApplyToDeserializerBuilder(DeserializerBuilder builder, PaSerializationContext serializationContext)
internal void ApplyToDeserializerBuilder(DeserializerBuilder builder, SerializationContext serializationContext)
{
builder
.WithDuplicateKeyChecking()
Expand All @@ -29,7 +29,7 @@ internal void ApplyToDeserializerBuilder(DeserializerBuilder builder, PaSerializ
AdditionalDeserializerConfiguration?.Invoke(builder);
}

internal void ApplyToSerializerBuilder(SerializerBuilder builder, PaSerializationContext serializationContext)
internal void ApplyToSerializerBuilder(SerializerBuilder builder, SerializationContext serializationContext)
{
ApplySerializerFormatting(builder);
AddTypeConverters(builder, serializationContext);
Expand All @@ -49,7 +49,7 @@ private void ApplySerializerFormatting(SerializerBuilder builder)
;
}

private void AddTypeConverters<TBuilder>(BuilderSkeleton<TBuilder> builder, PaSerializationContext serializationContext)
private void AddTypeConverters<TBuilder>(BuilderSkeleton<TBuilder> builder, SerializationContext serializationContext)
where TBuilder : BuilderSkeleton<TBuilder>
{
builder.WithTypeConverter(new PFxExpressionYamlConverter(PFxExpressionYamlFormatting));
Expand Down
6 changes: 3 additions & 3 deletions src/Persistence/PaYaml/Serialization/YamlConverterOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization;
public abstract class YamlConverter<T> : IYamlTypeConverter
{
protected YamlConverter()
: this(new PaSerializationContext())
: this(new SerializationContext())
{
}

protected YamlConverter(PaSerializationContext serializationContext)
protected YamlConverter(SerializationContext serializationContext)
{
SerializationContext = serializationContext ?? throw new ArgumentNullException(nameof(serializationContext));
}

public Type Type { get; } = typeof(T);

public PaSerializationContext SerializationContext { get; }
public SerializationContext SerializationContext { get; }

/// <summary>
/// The default implementation returns true when <paramref name="type"/> equals typeof(<typeparamref name="T"/>).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization;

internal static class PaYamlDotNetExtensions
internal static class YamlDotNetExtensions
{
private static readonly NullNodeDeserializer _nullNodeDeserializer = new();
private static readonly Type _typeofObject = typeof(object);
Expand All @@ -32,13 +32,13 @@ public static void EmitNull(this IEmitter emitter)
emitter.Emit(_nullImplicitPlainScalar);
}

public static PaYamlLocation? ToYamlLocation(this Mark mark)
public static YamlLocation? ToYamlLocation(this Mark mark)
{
if (mark.Equals(Mark.Empty))
{
return null;
}

return new PaYamlLocation(mark.Line, mark.Column);
return new YamlLocation(mark.Line, mark.Column);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization;

public static class PaYamlSerializer
public static class YamlSerializer
{
private static readonly Encoding Utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);

Expand Down Expand Up @@ -48,7 +48,7 @@ private static void WriteTextWriter<TValue>(TextWriter writer, in TValue? value,
var targetType = typeof(TValue);

// Configure the YamlDotNet serializer
using var serializationContext = new PaSerializationContext();
using var serializationContext = new SerializationContext();
var builder = new SerializerBuilder();
options.ApplyToSerializerBuilder(builder, serializationContext);
serializationContext.ValueSerializer = builder.BuildValueSerializer();
Expand Down Expand Up @@ -100,7 +100,7 @@ private static void WriteTextWriter<TValue>(TextWriter writer, in TValue? value,
options ??= PaYamlSerializerOptions.Default;

// Configure the YamlDotNet serializer
using var serializationContext = new PaSerializationContext();
using var serializationContext = new SerializationContext();
var builder = new DeserializerBuilder();
options.ApplyToDeserializerBuilder(builder, serializationContext);
serializationContext.ValueDeserializer = builder.BuildValueDeserializer();
Expand Down

0 comments on commit 867f193

Please sign in to comment.