Skip to content
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

Fix EdmStructuredObject default value getter #1949

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adzhilyanov
Copy link
Contributor

@adzhilyanov adzhilyanov commented Nov 5, 2019

Issues

Activator.CreateInstance(clrType) does not work when clrType is System.String or System.Byte[] (System.MissingMethodException : No parameterless constructor defined for this object.) which are mapped to Edm.String and Edm.Binary.

Description

Return empty string when the type is Edm.String[Nullable=False] and empty array when the type is Edm.Binary[Nullable=False].

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

Not sure what to do about Edm.Stream, Edm.Geography** and Edm.Geometry** properties.

@@ -221,6 +221,14 @@ internal static object GetDefaultValue(IEdmTypeReference propertyType)
(isCollection && propertyType.AsCollection().ElementType().IsPrimitive()))
{
// primitive or primitive collection
if (clrType == typeof(string))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edm.Primitive (System.String) is a built-in Primitive type.

EdmStructuredObject is used for complex or entity instance, the type of them is structured type. So, I don't know why should we add "primitive type" into "structured type"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, maybe the title is a bit misleading. It should be something like 'Fix EdmStructuredObject's properties default value getter'.
You are correct, but the EdmStructuredObject has properties, which can be primitives. So when you try to get a property from the EdmStructuredObject, if the property does not exist, a default value is returned. This PR aimed to fix how the default value for a property is obtained - fixing the GetDefaultValue method (which is used from TryGetPropertyValue). I don't know if this is the right place for the GetDefaultValue though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants