Skip to content

#136 fixed #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

#if NET6_0_OR_GREATER
namespace Tynamix.ObjectFiller.Test.BugfixTests
{
public record Product
{
public string Name { get; init; }
public int CategoryId { get; set; }
}

public record Person(string Name, string Username);

[TestClass]
public class Bug136RecordsObjectReferenceException
{
[TestMethod]
public void RecordsShouldBeFilled()
{
Filler<Product> filler = new Filler<Product>();
var product = filler.Create();
Assert.IsNotNull(product);
Assert.IsFalse(string.IsNullOrWhiteSpace(product.Name));

var filler2 = new Filler<Person>();
var person = filler2.Create();
Assert.IsNotNull(person);
Assert.IsFalse(string.IsNullOrWhiteSpace(person.Name));
Assert.IsFalse(string.IsNullOrWhiteSpace(person.Username));
}
}
}
#endif
2 changes: 1 addition & 1 deletion Tynamix.ObjectFiller/NetTypeApiExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static IEnumerable<MethodInfo> GetMethods(this Type source)
internal static MethodInfo GetSetterMethod(this PropertyInfo source)
{
#if NETSTANDARD
return source.SetMethod;
return source?.SetMethod;
#else
return source.GetSetMethod(true);
#endif
Expand Down