Skip to content

Commit bf7e7a7

Browse files
Fix bugs of source gens found during main port v9 (#4670)
* Fix problems in auto serialization source gen * Fix auto implement property source gen handling arrays and nullables correctly * Fix nullable handling in auto property source gen * Fix warning
1 parent 9f33ea3 commit bf7e7a7

File tree

195 files changed

+4059
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+4059
-30
lines changed

Source/Csla.Generators/cs/AutoImplementProperties/Csla.Generator.AutoImplementProperties.CSharp.Tests/AutoImplementPropertiesGeneratorTests.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Csla.Generator.AutoImplementProperties.CSharp.AutoImplement;
2-
using Microsoft.VisualStudio.TestTools.UnitTesting;
32

43

54
namespace Csla.Generator.Tests
@@ -162,5 +161,45 @@ public partial class BOTest : BusinessBase<BOTest>
162161
""";
163162
await TestHelper<IncrementalAutoImplementPropertiesPartialsGenerator>.Verify(source);
164163
}
164+
165+
public static IEnumerable<object[]> Case08TestData()
166+
{
167+
var nonNullableBuiltInTypes = new string[] { "bool", "byte", "sbyte", "char", "decimal", "double", "float", "int", "uint", "long", "ulong", "short", "ushort" };
168+
169+
foreach (var item in nonNullableBuiltInTypes)
170+
{
171+
yield return new object[] { item };
172+
yield return new object[] { $"{item}?" };
173+
yield return new object[] { $"{item}[]" };
174+
yield return new object[] { $"{item}[]?" };
175+
}
176+
177+
var nullableBuiltInTypes = new string[] { "string", "object" };
178+
179+
foreach (var item in nullableBuiltInTypes)
180+
{
181+
yield return new object[] { item };
182+
yield return new object[] { $"{item}?" };
183+
yield return new object[] { $"{item}[]" };
184+
yield return new object[] { $"{item}[]?" };
185+
}
186+
}
187+
188+
[DataTestMethod]
189+
[DynamicData(nameof(Case08TestData))]
190+
public async Task Case08(string type)
191+
{
192+
var source = $$"""
193+
namespace Test;
194+
195+
[Csla.CslaImplementProperties]
196+
public partial class BusinessBaseTestClass : Csla.BusinessBase<BusinessBaseTestClass>
197+
{
198+
public partial {{type}} Name { get; private set; }
199+
}
200+
""";
201+
202+
await TestHelper<IncrementalAutoImplementPropertiesPartialsGenerator>.Verify(source);
203+
}
165204
}
166205
}

Source/Csla.Generators/cs/AutoImplementProperties/Csla.Generator.AutoImplementProperties.CSharp.Tests/Snapshots/AutoImplementPropertiesGeneratorTests.Case01#ReadOnlyPOCO.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public partial class ReadOnlyPOCO
1111
public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name));
1212
public partial string Name
1313
{
14-
get => GetProperty(NameProperty);
14+
get => GetProperty(NameProperty)!;
1515
private set => LoadProperty(NameProperty, value);
1616
}
1717
}

Source/Csla.Generators/cs/AutoImplementProperties/Csla.Generator.AutoImplementProperties.CSharp.Tests/Snapshots/AutoImplementPropertiesGeneratorTests.Case02#BusinessBaseTestClass.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public partial class BusinessBaseTestClass
1111
public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name));
1212
public partial string Name
1313
{
14-
get => GetProperty(NameProperty);
14+
get => GetProperty(NameProperty)!;
1515
private set => SetProperty(NameProperty, value);
1616
}
1717
}

Source/Csla.Generators/cs/AutoImplementProperties/Csla.Generator.AutoImplementProperties.CSharp.Tests/Snapshots/AutoImplementPropertiesGeneratorTests.Case03#BusinessBaseTestClass.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public partial class BusinessBaseTestClass
1111
public static readonly PropertyInfo<global::Test2.GenericType<string>> NameProperty = RegisterProperty<global::Test2.GenericType<string>>(nameof(Name));
1212
public partial global::Test2.GenericType<string> Name
1313
{
14-
get => GetProperty(NameProperty);
14+
get => GetProperty(NameProperty)!;
1515
private set => SetProperty(NameProperty, value);
1616
}
1717
}

Source/Csla.Generators/cs/AutoImplementProperties/Csla.Generator.AutoImplementProperties.CSharp.Tests/Snapshots/AutoImplementPropertiesGeneratorTests.Case04#BusinessBaseTestClass.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public partial class BusinessBaseTestClass
1111
public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name));
1212
public partial string Name
1313
{
14-
get => GetProperty(NameProperty);
14+
get => GetProperty(NameProperty)!;
1515
private set => SetProperty(NameProperty, value);
1616
}
1717
}

Source/Csla.Generators/cs/AutoImplementProperties/Csla.Generator.AutoImplementProperties.CSharp.Tests/Snapshots/AutoImplementPropertiesGeneratorTests.Case05#BusinessBaseTestClass.g.verified.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public partial class BusinessBaseTestClass
1111
public static readonly PropertyInfo<global::Test2.UniqueType1> UniqueNameProperty = RegisterProperty<global::Test2.UniqueType1>(nameof(UniqueName));
1212
public partial global::Test2.UniqueType1 UniqueName
1313
{
14-
get => GetProperty(UniqueNameProperty);
14+
get => GetProperty(UniqueNameProperty)!;
1515
private set => SetProperty(UniqueNameProperty, value);
1616
}
1717
public static readonly PropertyInfo<global::Test3.NonUniqueType> NonUniqueProperty = RegisterProperty<global::Test3.NonUniqueType>(nameof(NonUnique));
1818
public partial global::Test3.NonUniqueType NonUnique
1919
{
20-
get => GetProperty(NonUniqueProperty);
20+
get => GetProperty(NonUniqueProperty)!;
2121
set => SetProperty(NonUniqueProperty, value);
2222
}
2323
}

Source/Csla.Generators/cs/AutoImplementProperties/Csla.Generator.AutoImplementProperties.CSharp.Tests/Snapshots/AutoImplementPropertiesGeneratorTests.Case06#CommandTest.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public partial class CommandTest
1111
public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(nameof(Name));
1212
public partial string Name
1313
{
14-
get => ReadProperty(NameProperty);
14+
get => ReadProperty(NameProperty)!;
1515
private set => LoadProperty(NameProperty, value);
1616
}
1717
}

Source/Csla.Generators/cs/AutoImplementProperties/Csla.Generator.AutoImplementProperties.CSharp.Tests/Snapshots/AutoImplementPropertiesGeneratorTests.Case07#BOTest.g.verified.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public partial class BOTest
1111
public static readonly PropertyInfo<global::Test.GenericType<global::Csla.Core.MobileDictionary<string, int>>> NameProperty = RegisterProperty<global::Test.GenericType<global::Csla.Core.MobileDictionary<string, int>>>(nameof(Name));
1212
public partial global::Test.GenericType<global::Csla.Core.MobileDictionary<string, int>> Name
1313
{
14-
get => GetProperty(NameProperty);
14+
get => GetProperty(NameProperty)!;
1515
private set => SetProperty(NameProperty, value);
1616
}
1717
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//HintName: BusinessBaseTestClass.g.cs
2+
//<auto-generated/>
3+
#nullable enable
4+
using System;
5+
using Csla;
6+
7+
namespace Test;
8+
9+
public partial class BusinessBaseTestClass
10+
{
11+
public static readonly PropertyInfo<bool> NameProperty = RegisterProperty<bool>(nameof(Name));
12+
public partial bool Name
13+
{
14+
get => GetProperty(NameProperty)!;
15+
private set => SetProperty(NameProperty, value);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//HintName: BusinessBaseTestClass.g.cs
2+
//<auto-generated/>
3+
#nullable enable
4+
using System;
5+
using Csla;
6+
7+
namespace Test;
8+
9+
public partial class BusinessBaseTestClass
10+
{
11+
public static readonly PropertyInfo<bool?> NameProperty = RegisterProperty<bool?>(nameof(Name));
12+
public partial bool? Name
13+
{
14+
get => GetProperty(NameProperty);
15+
private set => SetProperty(NameProperty, value);
16+
}
17+
}

0 commit comments

Comments
 (0)