-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Feature - Extension EverythingThe extension everything featureThe extension everything featureResolution-FixedThe bug has been fixed and/or the requested behavior has been implementedThe bug has been fixed and/or the requested behavior has been implemented
Description
Version Used:
Visual Studio 17.14.2 Preview 1.0
10.0.100-preview.4.25258.110
Steps to Reproduce:
- Created an extension member property for an interface (code below)
- If I create the Person in the same assembly, I can use the property.
- If I write a unit test in a separate assembly, the property is not available.
Expected Behavior:
The property should be available.
Actual Behavior:
I can only access the property using code like this:
PersonExtensions.get_Age(person);
Note
- Extension member extension methods work fine.
Other Behavior
I'm not sure if any of the below is working yet.
- I have to manually add the namespace for the extension. Visual Studio does not seem to recognize it.
- In the assembly where the extension property is, "Find All References" does not work.
- CoPilot has issues creating XML documentation. Also recommends that I change to normal extension methods.
Interface and Extension Member Property
namespace DotNetTips.Spargine.Tester.Extensions;
public static class PersonExtensions
{
extension([NotNull] IPerson person)
{
public string FullName => $"{person.FirstName} {person.LastName}";
public TimeSpan Age => DateTimeOffset.UtcNow.Subtract(person.BornOn);
}
}
namespace DotNetTips.Spargine.Tester.Models.RefTypes;
public interface IPerson
{
[DataType(DataType.Date)]
public DateTimeOffset BornOn { get; set; }
[Phone(ErrorMessage = "The cell phone number is not in a valid format.")]
public string CellPhone { get; set; }
[EmailAddress(ErrorMessage = "The email address is not in a valid format.")]
public string Email { get; set; }
[StringLength(50, ErrorMessage = "The first name must not exceed 50 characters.")]
public string FirstName { get; set; }
[StringLength(50, ErrorMessage = "The last name must not exceed 50 characters.")]
public string LastName { get; set; }
[Phone(ErrorMessage = "The phone number is not in a valid format.")]
public string Phone { get; set; }
}
Metadata
Metadata
Assignees
Labels
Feature - Extension EverythingThe extension everything featureThe extension everything featureResolution-FixedThe bug has been fixed and/or the requested behavior has been implementedThe bug has been fixed and/or the requested behavior has been implemented