Make JsonPropertyNameAttribute.Name readonly (dotnet/corefx#37829)
authorMaryam Ariyan <maryam.ariyan@microsoft.com>
Tue, 28 May 2019 19:27:20 +0000 (12:27 -0700)
committerAhson Khan <ahkha@microsoft.com>
Tue, 28 May 2019 19:27:20 +0000 (12:27 -0700)
Rename ctor arg to name

Fixes: dotnet/corefx#37552

Commit migrated from https://github.com/dotnet/corefx/commit/e8990ae04e4ef62f5ccb143352472c9b4d5d5968

src/libraries/System.Text.Json/docs/SerializerProgrammingModel.md
src/libraries/System.Text.Json/ref/System.Text.Json.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonPropertyNameAttribute.cs

index 73d4d7e..6c5dc08 100644 (file)
@@ -128,8 +128,8 @@ namespace System.Text.Json.Serialization
     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false)]
     public sealed class JsonPropertyNameAttribute : System.Text.Json.Serialization.JsonAttribute
     {
-        public JsonPropertyNameAttribute(string propertyName) { }
-        public string Name { get; set; }
+        public JsonPropertyNameAttribute(string name) { }
+        public string Name { get; }
     }
 
     public abstract partial class JsonNamingPolicy
index f778372..fbf9ea8 100644 (file)
@@ -374,8 +374,8 @@ namespace System.Text.Json.Serialization
     [System.AttributeUsageAttribute(System.AttributeTargets.Property, AllowMultiple=false)]
     public sealed partial class JsonPropertyNameAttribute : System.Text.Json.Serialization.JsonAttribute
     {
-        public JsonPropertyNameAttribute(string propertyName) { }
-        public string Name { get { throw null; } set { } }
+        public JsonPropertyNameAttribute(string name) { }
+        public string Name { get { throw null; } }
     }
     public static partial class JsonSerializer
     {
index e3a5ecb..563ed5d 100644 (file)
@@ -14,15 +14,15 @@ namespace System.Text.Json.Serialization
         /// <summary>
         /// Initializes a new instance of <see cref="JsonPropertyNameAttribute"/> with the specified property name.
         /// </summary>
-        /// <param name="propertyName">The name of the property.</param>
-        public JsonPropertyNameAttribute(string propertyName)
+        /// <param name="name">The name of the property.</param>
+        public JsonPropertyNameAttribute(string name)
         {
-            Name = propertyName;
+            Name = name;
         }
 
         /// <summary>
         /// The name of the property.
         /// </summary>
-        public string Name { get; set; }
+        public string Name { get; }
     }
 }