Only generate setters and getters for public properties (#47)

* Only generate setters and getters for public properties

* .
This commit is contained in:
Stef Heyenrath
2022-12-13 19:18:30 +01:00
committed by GitHub
parent 72a40e6f6a
commit d340c6af7c
10 changed files with 158 additions and 12 deletions
@@ -96,9 +96,13 @@ using System;
{
var type = GetPropertyType(property, out var isReplaced);
(string propertyType, string? propertyName, string getSet) = isReplaced ?
property.ToPropertyDetails(type) :
property.ToPropertyDetails();
var getterSetter = isReplaced ? property.ToPropertyDetails(type) : property.ToPropertyDetails();
if (getterSetter is null)
{
continue;
}
var propertyName = getterSetter.Value.PropertyName;
if (property.IsIndexer)
{
@@ -106,7 +110,7 @@ using System;
propertyName = $"this[{string.Join(", ", methodParameters)}]";
}
str.AppendLine($" {propertyType} {propertyName} {getSet}");
str.AppendLine($" {getterSetter.Value.PropertyType} {propertyName} {getterSetter.Value.GetSet}");
str.AppendLine();
}