Skip to content

Commit

Permalink
Fix the public API warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhg committed Oct 1, 2021
1 parent 74b2c5b commit 46b67e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
3 changes: 0 additions & 3 deletions src/Microsoft.AspNetCore.OData/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,6 @@ Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderBase.EnsureFlattene
Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderBase.ExpressionBinderBase(System.IServiceProvider requestContainer) -> void
Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderBase.GetDynamicPropertyContainer(Microsoft.OData.UriParser.SingleValueOpenPropertyAccessNode openNode) -> System.Reflection.PropertyInfo
Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderBase.GetFlattenedPropertyExpression(string propertyPath) -> System.Linq.Expressions.Expression
Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderHelper
Microsoft.AspNetCore.OData.Query.Expressions.FilterBinder
Microsoft.AspNetCore.OData.Query.Expressions.FilterBinder.FilterBinder(System.IServiceProvider requestContainer) -> void
Microsoft.AspNetCore.OData.Query.Expressions.ISelectExpandBinder
Expand All @@ -840,8 +839,6 @@ Microsoft.AspNetCore.OData.Query.Expressions.ISelectExpandBinder.Bind(System.Lin
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinder
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinder.SelectExpandBinder() -> void
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinderContext
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinderContext.QueryContext.get -> Microsoft.AspNetCore.OData.Query.ODataQueryContext
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinderContext.QueryContext.set -> void
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinderContext.QuerySettings.get -> Microsoft.AspNetCore.OData.Query.ODataQuerySettings
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinderContext.QuerySettings.set -> void
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinderContext.SelectExpandBinderContext() -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ internal Expression ProjectAsWrapper(SelectExpandBinderContext context, Expressi
}
}

internal Expression CreatePropertyNameExpression(SelectExpandBinderContext context, IEdmStructuredType elementType, IEdmProperty property, Expression source)
internal static Expression CreatePropertyNameExpression(SelectExpandBinderContext context, IEdmStructuredType elementType, IEdmProperty property, Expression source)
{
Contract.Assert(elementType != null);
Contract.Assert(property != null);
Expand Down Expand Up @@ -146,7 +146,7 @@ internal Expression CreatePropertyNameExpression(SelectExpandBinderContext conte
return Expression.Constant(property.Name);
}

internal Expression CreatePropertyValueExpression(SelectExpandBinderContext context, IEdmStructuredType elementType, IEdmProperty property, Expression source, FilterClause filterClause)
internal static Expression CreatePropertyValueExpression(SelectExpandBinderContext context, IEdmStructuredType elementType, IEdmProperty property, Expression source, FilterClause filterClause)
{
Contract.Assert(elementType != null);
Contract.Assert(property != null);
Expand Down Expand Up @@ -944,7 +944,7 @@ private static Expression GetNullCheckExpression(IEdmStructuralProperty property
return null;
}

private Expression GetNullCheckExpression(SelectExpandBinderContext context, IEdmNavigationProperty propertyToExpand, Expression propertyValue,
private static Expression GetNullCheckExpression(SelectExpandBinderContext context, IEdmNavigationProperty propertyToExpand, Expression propertyValue,
SelectExpandClause projection)
{
if (projection == null || propertyToExpand.Type.IsCollection())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1357,25 +1357,25 @@ public void CreatePropertyNameExpression_ReturnsCorrectExpression()

// Act & Assert
// #1. Base property on base type
Expression property = binder.CreatePropertyNameExpression(_selectExpandBinderContext, _customer, baseProperty, source);
Expression property = SelectExpandBinder.CreatePropertyNameExpression(_selectExpandBinderContext, _customer, baseProperty, source);
Assert.Equal(ExpressionType.Constant, property.NodeType);
Assert.Equal(typeof(string), property.Type);
Assert.Equal("PrivateOrder", (property as ConstantExpression).Value);

// #2. Base property on derived type
property = binder.CreatePropertyNameExpression(_selectExpandBinderContext, vipCustomer, baseProperty, source);
property = SelectExpandBinder.CreatePropertyNameExpression(_selectExpandBinderContext, vipCustomer, baseProperty, source);
Assert.Equal(ExpressionType.Constant, property.NodeType);
Assert.Equal(typeof(string), property.Type);
Assert.Equal("PrivateOrder", (property as ConstantExpression).Value);

// #3. Derived property on base type
property = binder.CreatePropertyNameExpression(_selectExpandBinderContext, _customer, derivedProperty, source);
property = SelectExpandBinder.CreatePropertyNameExpression(_selectExpandBinderContext, _customer, derivedProperty, source);
Assert.Equal(ExpressionType.Conditional, property.NodeType);
Assert.Equal(typeof(string), property.Type);
Assert.Equal("IIF((aCustomer Is QueryVipCustomer), \"Birthday\", null)", property.ToString());

// #4. Derived property on derived type.
property = binder.CreatePropertyNameExpression(_selectExpandBinderContext, vipCustomer, derivedProperty, source);
property = SelectExpandBinder.CreatePropertyNameExpression(_selectExpandBinderContext, vipCustomer, derivedProperty, source);
Assert.Equal(ExpressionType.Constant, property.NodeType);
Assert.Equal(typeof(string), property.Type);
Assert.Equal("Birthday", (property as ConstantExpression).Value);
Expand All @@ -1394,7 +1394,7 @@ public void CreatePropertyNameExpression_ReturnsConstantExpression_IfPropertyTyp
Expression source = Expression.Parameter(typeof(QueryCustomer), "aCustomer");

// Act
Expression property = _binder.CreatePropertyNameExpression(_selectExpandBinderContext, _customer, edmProperty, source);
Expression property = SelectExpandBinder.CreatePropertyNameExpression(_selectExpandBinderContext, _customer, edmProperty, source);

// Assert
Assert.Equal(ExpressionType.Constant, property.NodeType);
Expand All @@ -1417,7 +1417,7 @@ public void CreatePropertyNameExpression_ThrowsODataException_IfMappingTypeIsNot
SelectExpandBinder binder = GetBinder<QueryCustomer>(model);

// Act & Assert
ExceptionAssert.Throws<ODataException>(() => binder.CreatePropertyNameExpression(_selectExpandBinderContext, _customer, subNameProperty, source),
ExceptionAssert.Throws<ODataException>(() => SelectExpandBinder.CreatePropertyNameExpression(_selectExpandBinderContext, _customer, subNameProperty, source),
"The provided mapping does not contain a resource for the resource type 'NS.SubCustomer'.");
}
#endregion
Expand All @@ -1435,7 +1435,7 @@ public void CreatePropertyValueExpression_NonDerivedNavigationProperty_ReturnsMe
Assert.NotNull(navProperty);

// Act
Expression propertyValue = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, navProperty, source, null);
Expression propertyValue = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, navProperty, source, null);

// Assert
Assert.Equal(ExpressionType.MemberAccess, propertyValue.NodeType);
Expand All @@ -1458,7 +1458,7 @@ public void CreatePropertyValueExpression_DerivedNavigationProperty_ReturnsPrope
Assert.NotNull(specialProperty);

// Act
Expression propertyValue = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, specialProperty, source, null);
Expression propertyValue = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, specialProperty, source, null);

// Assert
Assert.Equal(String.Format("({0} As QueryVipCustomer).{1}", source.ToString(), property), propertyValue.ToString());
Expand All @@ -1480,7 +1480,7 @@ public void CreatePropertyValueExpression_DerivedValueProperty_ReturnsPropertyAc
Assert.NotNull(vipCustomer);

// Act
Expression propertyValue = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, edmProperty, source, null);
Expression propertyValue = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, edmProperty, source, null);

// Assert
Assert.Equal(String.Format("Convert(({0} As QueryVipCustomer).{1}, Nullable`1)", source.ToString(), property), propertyValue.ToString());
Expand All @@ -1502,7 +1502,7 @@ public void CreatePropertyValueExpression_DerivedReferenceProperty_ReturnsProper
Assert.NotNull(vipCustomer);

// Act
Expression propertyValue = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, edmProperty, source, null);
Expression propertyValue = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, edmProperty, source, null);

// Assert
Assert.Equal(String.Format("({0} As QueryVipCustomer).{1}", source.ToString(), property), propertyValue.ToString());
Expand All @@ -1517,7 +1517,7 @@ public void CreatePropertyValueExpression_HandleNullPropagationTrue_AddsNullChec
IEdmProperty idProperty = _customer.StructuralProperties().Single(p => p.Name == "Id");

// Act
Expression property = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, idProperty, source, null);
Expression property = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, idProperty, source, null);

// Assert
// NetFx and NetCore differ in the way Expression is converted to a string.
Expand Down Expand Up @@ -1554,7 +1554,7 @@ public void CreatePropertyValueExpression_HandleNullPropagationFalse_ConvertsToN
IEdmProperty idProperty = _customer.StructuralProperties().Single(p => p.Name == "Id");

// Act
Expression property = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, idProperty, source, filterClause: null);
Expression property = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, idProperty, source, filterClause: null);

// Assert
Assert.Equal(String.Format("Convert({0}.Id, Nullable`1)", source.ToString()), property.ToString());
Expand Down Expand Up @@ -1587,7 +1587,7 @@ public void CreatePropertyValueExpression_Collection_ThrowsODataException_IfMapp

// Act & Assert
ExceptionAssert.Throws<ODataException>(
() => _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, ordersProperty, source, expandItem.FilterOption),
() => SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, ordersProperty, source, expandItem.FilterOption),
String.Format("The provided mapping does not contain a resource for the resource type '{0}'.",
ordersProperty.Type.Definition.AsElementType().FullTypeName()));
}
Expand Down Expand Up @@ -1616,7 +1616,7 @@ public void CreatePropertyValueExpression_Collection_Works_HandleNullPropagation
Assert.NotNull(expandItem.FilterOption);

// Act
var filterInExpand = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, ordersProperty, source, expandItem.FilterOption);
var filterInExpand = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _customer, ordersProperty, source, expandItem.FilterOption);

// Assert
if (nullOption == HandleNullPropagationOption.True)
Expand Down Expand Up @@ -1691,7 +1691,7 @@ public void CreatePropertyValueExpression_Single_Works_IfSettingIsOff()
Assert.NotNull(expandItem.FilterOption);

// Act
var filterInExpand = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _order, customerProperty, order, expandItem.FilterOption);
var filterInExpand = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _order, customerProperty, order, expandItem.FilterOption);

// Assert
var customer = Expression.Lambda(filterInExpand).Compile().DynamicInvoke() as QueryCustomer;
Expand Down Expand Up @@ -1725,7 +1725,7 @@ public void CreatePropertyValueExpression_Single_Works_HandleNullPropagationOpti
Assert.NotNull(expandItem.FilterOption);

// Act
var filterInExpand = _binder.CreatePropertyValueExpression(_selectExpandBinderContext, _order, customerProperty, source, expandItem.FilterOption);
var filterInExpand = SelectExpandBinder.CreatePropertyValueExpression(_selectExpandBinderContext, _order, customerProperty, source, expandItem.FilterOption);

// Assert
if (nullOption == HandleNullPropagationOption.True)
Expand Down

0 comments on commit 46b67e2

Please sign in to comment.