From eb623f8eeac83f9769e3a531e72f0be6c6cfee63 Mon Sep 17 00:00:00 2001 From: "Andrew Petrochuk (from Dev Box)" Date: Wed, 15 May 2024 19:36:37 -0700 Subject: [PATCH] Removed "Pa" prefix where is not necessary --- .../NamedObjectSequenceSerializationTests.cs | 4 ++-- .../Serialization/PFxExpressionYamlConverterTests.cs | 4 ++-- .../PaYaml/Serialization/PaYamlSerializerTests.cs | 12 ++++++------ .../PaYaml/Serialization/SerializationTestBase.cs | 12 ++++++------ src/Persistence/PaYaml/Models/INamedObject.cs | 2 +- src/Persistence/PaYaml/Models/NamedObject.cs | 2 +- .../Models/{PaYamlLocation.cs => YamlLocation.cs} | 4 ++-- .../PaYaml/Serialization/NamedObjectYamlConverter.cs | 2 +- .../PaYaml/Serialization/PaSerializationContext.cs | 2 +- .../PaYaml/Serialization/PaYamlSerializerOptions.cs | 6 +++--- .../PaYaml/Serialization/YamlConverterOfT.cs | 6 +++--- ...mlDotNetExtensions.cs => YamlDotNetExtensions.cs} | 6 +++--- .../{PaYamlSerializer.cs => YamlSerializer.cs} | 6 +++--- 13 files changed, 34 insertions(+), 34 deletions(-) rename src/Persistence/PaYaml/Models/{PaYamlLocation.cs => YamlLocation.cs} (74%) rename src/Persistence/PaYaml/Serialization/{PaYamlDotNetExtensions.cs => YamlDotNetExtensions.cs} (90%) rename src/Persistence/PaYaml/Serialization/{PaYamlSerializer.cs => YamlSerializer.cs} (96%) diff --git a/src/Persistence.Tests/PaYaml/Serialization/NamedObjectSequenceSerializationTests.cs b/src/Persistence.Tests/PaYaml/Serialization/NamedObjectSequenceSerializationTests.cs index 00b51712..b0b96bf0 100644 --- a/src/Persistence.Tests/PaYaml/Serialization/NamedObjectSequenceSerializationTests.cs +++ b/src/Persistence.Tests/PaYaml/Serialization/NamedObjectSequenceSerializationTests.cs @@ -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(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(serializationContext)); diff --git a/src/Persistence.Tests/PaYaml/Serialization/PFxExpressionYamlConverterTests.cs b/src/Persistence.Tests/PaYaml/Serialization/PFxExpressionYamlConverterTests.cs index eb238762..590a932d 100644 --- a/src/Persistence.Tests/PaYaml/Serialization/PFxExpressionYamlConverterTests.cs +++ b/src/Persistence.Tests/PaYaml/Serialization/PFxExpressionYamlConverterTests.cs @@ -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)); diff --git a/src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs b/src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs index da40c3fc..cdff74a2 100644 --- a/src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs +++ b/src/Persistence.Tests/PaYaml/Serialization/PaYamlSerializerTests.cs @@ -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(File.ReadAllText(path)); + var paFileRoot = YamlSerializer.Deserialize(File.ReadAllText(path)); paFileRoot.ShouldNotBeNull(); // Top level properties @@ -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(File.ReadAllText(path)); + var paFileRoot = YamlSerializer.Deserialize(File.ReadAllText(path)); paFileRoot.ShouldNotBeNull(); // Top level properties @@ -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(File.ReadAllText(path)); + var paFileRoot = YamlSerializer.Deserialize(File.ReadAllText(path)); paFileRoot.ShouldNotBeNull(); // Top level properties @@ -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(File.ReadAllText(path)); + var paFileRoot = YamlSerializer.Deserialize(File.ReadAllText(path)); paFileRoot.ShouldNotBeNull(); // Top level properties @@ -112,10 +112,10 @@ public void DeserializeExamplePaYamlSingleFileApp() public void RoundTripFromYaml(string path) { var originalYaml = File.ReadAllText(path); - var paFileRoot = PaYamlSerializer.Deserialize(originalYaml); + var paFileRoot = YamlSerializer.Deserialize(originalYaml); paFileRoot.ShouldNotBeNull(); - var roundTrippedYaml = PaYamlSerializer.Serialize(paFileRoot); + var roundTrippedYaml = YamlSerializer.Serialize(paFileRoot); TestContext.WriteTextWithLineNumbers(roundTrippedYaml, "roundTrippedYaml:"); roundTrippedYaml.Should().BeYamlEquivalentTo(originalYaml); } diff --git a/src/Persistence.Tests/PaYaml/Serialization/SerializationTestBase.cs b/src/Persistence.Tests/PaYaml/Serialization/SerializationTestBase.cs index 1ed8adf1..5a797a48 100644 --- a/src/Persistence.Tests/PaYaml/Serialization/SerializationTestBase.cs +++ b/src/Persistence.Tests/PaYaml/Serialization/SerializationTestBase.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization; @@ -15,7 +15,7 @@ protected string SerializeViaYamlDotNet(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(); @@ -24,7 +24,7 @@ protected string SerializeViaYamlDotNet(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); } @@ -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(); @@ -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() ; } -} \ No newline at end of file +} diff --git a/src/Persistence/PaYaml/Models/INamedObject.cs b/src/Persistence/PaYaml/Models/INamedObject.cs index a4af852e..5c7fd89c 100644 --- a/src/Persistence/PaYaml/Models/INamedObject.cs +++ b/src/Persistence/PaYaml/Models/INamedObject.cs @@ -9,5 +9,5 @@ public interface INamedObject { TName Name { get; } TValue Value { get; } - PaYamlLocation? Start { get; } + YamlLocation? Start { get; } } diff --git a/src/Persistence/PaYaml/Models/NamedObject.cs b/src/Persistence/PaYaml/Models/NamedObject.cs index 3676ebec..2656684b 100644 --- a/src/Persistence/PaYaml/Models/NamedObject.cs +++ b/src/Persistence/PaYaml/Models/NamedObject.cs @@ -20,5 +20,5 @@ public record NamedObject(TName Name, TValue Value) : INamedObjec where TName : notnull where TValue : notnull { - public PaYamlLocation? Start { get; init; } + public YamlLocation? Start { get; init; } } diff --git a/src/Persistence/PaYaml/Models/PaYamlLocation.cs b/src/Persistence/PaYaml/Models/YamlLocation.cs similarity index 74% rename from src/Persistence/PaYaml/Models/PaYamlLocation.cs rename to src/Persistence/PaYaml/Models/YamlLocation.cs index d703f8a5..d64a22c7 100644 --- a/src/Persistence/PaYaml/Models/PaYamlLocation.cs +++ b/src/Persistence/PaYaml/Models/YamlLocation.cs @@ -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)) { diff --git a/src/Persistence/PaYaml/Serialization/NamedObjectYamlConverter.cs b/src/Persistence/PaYaml/Serialization/NamedObjectYamlConverter.cs index 2003a98f..9ce9223b 100644 --- a/src/Persistence/PaYaml/Serialization/NamedObjectYamlConverter.cs +++ b/src/Persistence/PaYaml/Serialization/NamedObjectYamlConverter.cs @@ -12,7 +12,7 @@ namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization; public class NamedObjectYamlConverter : YamlConverter> where TValue : notnull { - public NamedObjectYamlConverter(PaSerializationContext serializationContext) + public NamedObjectYamlConverter(SerializationContext serializationContext) : base(serializationContext) { } diff --git a/src/Persistence/PaYaml/Serialization/PaSerializationContext.cs b/src/Persistence/PaYaml/Serialization/PaSerializationContext.cs index ca6e629c..27504c66 100644 --- a/src/Persistence/PaYaml/Serialization/PaSerializationContext.cs +++ b/src/Persistence/PaYaml/Serialization/PaSerializationContext.cs @@ -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; diff --git a/src/Persistence/PaYaml/Serialization/PaYamlSerializerOptions.cs b/src/Persistence/PaYaml/Serialization/PaYamlSerializerOptions.cs index 7845446a..5597c058 100644 --- a/src/Persistence/PaYaml/Serialization/PaYamlSerializerOptions.cs +++ b/src/Persistence/PaYaml/Serialization/PaYamlSerializerOptions.cs @@ -20,7 +20,7 @@ public record PaYamlSerializerOptions public Action? AdditionalSerializerConfiguration { get; init; } - internal void ApplyToDeserializerBuilder(DeserializerBuilder builder, PaSerializationContext serializationContext) + internal void ApplyToDeserializerBuilder(DeserializerBuilder builder, SerializationContext serializationContext) { builder .WithDuplicateKeyChecking() @@ -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); @@ -49,7 +49,7 @@ private void ApplySerializerFormatting(SerializerBuilder builder) ; } - private void AddTypeConverters(BuilderSkeleton builder, PaSerializationContext serializationContext) + private void AddTypeConverters(BuilderSkeleton builder, SerializationContext serializationContext) where TBuilder : BuilderSkeleton { builder.WithTypeConverter(new PFxExpressionYamlConverter(PFxExpressionYamlFormatting)); diff --git a/src/Persistence/PaYaml/Serialization/YamlConverterOfT.cs b/src/Persistence/PaYaml/Serialization/YamlConverterOfT.cs index 8035778e..5bfa14e2 100644 --- a/src/Persistence/PaYaml/Serialization/YamlConverterOfT.cs +++ b/src/Persistence/PaYaml/Serialization/YamlConverterOfT.cs @@ -10,18 +10,18 @@ namespace Microsoft.PowerPlatform.PowerApps.Persistence.PaYaml.Serialization; public abstract class YamlConverter : 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; } /// /// The default implementation returns true when equals typeof(). diff --git a/src/Persistence/PaYaml/Serialization/PaYamlDotNetExtensions.cs b/src/Persistence/PaYaml/Serialization/YamlDotNetExtensions.cs similarity index 90% rename from src/Persistence/PaYaml/Serialization/PaYamlDotNetExtensions.cs rename to src/Persistence/PaYaml/Serialization/YamlDotNetExtensions.cs index 20c91167..748c67b9 100644 --- a/src/Persistence/PaYaml/Serialization/PaYamlDotNetExtensions.cs +++ b/src/Persistence/PaYaml/Serialization/YamlDotNetExtensions.cs @@ -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); @@ -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); } } diff --git a/src/Persistence/PaYaml/Serialization/PaYamlSerializer.cs b/src/Persistence/PaYaml/Serialization/YamlSerializer.cs similarity index 96% rename from src/Persistence/PaYaml/Serialization/PaYamlSerializer.cs rename to src/Persistence/PaYaml/Serialization/YamlSerializer.cs index c780fa68..bf743c08 100644 --- a/src/Persistence/PaYaml/Serialization/PaYamlSerializer.cs +++ b/src/Persistence/PaYaml/Serialization/YamlSerializer.cs @@ -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); @@ -48,7 +48,7 @@ private static void WriteTextWriter(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(); @@ -100,7 +100,7 @@ private static void WriteTextWriter(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();