Skip to content

Commit

Permalink
Update public Api for 0.6 (part 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinadragon0515 committed Aug 3, 2016
1 parent 506f693 commit d8c8e1a
Show file tree
Hide file tree
Showing 44 changed files with 317 additions and 226 deletions.
20 changes: 8 additions & 12 deletions src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,21 @@
#region CA1006 Nested Generic Type
[assembly: SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "Microsoft.Restier.Core.ApiBaseExtensions.#QueryAsync`1(Microsoft.Restier.Core.ApiBase,System.Linq.IQueryable`1<!!0>,System.Threading.CancellationToken)")]
[assembly: SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "Microsoft.Restier.Core.ApiBaseExtensions.#QueryAsync`2(Microsoft.Restier.Core.ApiBase,System.Linq.IQueryable`1<!!0>,System.Linq.Expressions.Expression`1<System.Func`2<System.Linq.IQueryable`1<!!0>,!!1>>,System.Threading.CancellationToken)")]
[assembly: SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "Microsoft.Restier.Core.Model.ModelContext.#EntityTypeKeyPropertiesMap")]
[assembly: SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "Microsoft.Restier.Core.Model.ModelContext.#ResourceTypeKeyPropertiesMap")]
[assembly: SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Scope = "member", Target = "Microsoft.Restier.Core.Query.QueryRequest.#Create`2(System.Linq.IQueryable`1<!!0>,System.Linq.Expressions.Expression`1<System.Func`2<System.Linq.IQueryable`1<!!0>,!!1>>,System.Nullable`1<System.Boolean>)")]
#endregion

#region CA1020 Few types in namespace
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Core")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Core.Exceptions")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Core.Model")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Core.Operation")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Providers.EntityFramework")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Providers.EntityFramework.Model")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Providers.EntityFramework.Query")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Providers.EntityFramework.Spatial")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Providers.EntityFramework.Submit")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Publishers.OData")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Publishers.OData.Batch")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Publishers.OData.Filters")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Publishers.OData.Formatter.Deserialization")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Publishers.OData.Formatter.Serialization")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Publishers.OData.Model")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Publishers.OData.Results")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Microsoft.Restier.Publishers.OData.Routing")]
Expand All @@ -80,17 +76,17 @@
[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.Restier.Publishers.OData.Routing.HttpConfigurationExtensions.#MapRestierRoute`1(System.Web.Http.HttpConfiguration,System.String,System.String,System.Func`1<Microsoft.Restier.Core.ApiBase>,Microsoft.Restier.Publishers.OData.Batch.RestierBatchHandler)")]
[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.Restier.Publishers.OData.Routing.HttpConfigurationExtensions.#MapRestierRoute`1(System.Web.Http.HttpConfiguration,System.String,System.String,Microsoft.Restier.Publishers.OData.Batch.RestierBatchHandler)")]
[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "Microsoft.Restier.Publishers.OData.Batch.RestierBatchHandler.#.ctor(System.Web.Http.HttpServer,System.Func`1<Microsoft.Restier.Core.ApiContext>)")]
[assembly: SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Scope = "type", Target = "Microsoft.Restier.Core.Exceptions.PreconditionFailedException")]
[assembly: SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Scope = "type", Target = "Microsoft.Restier.Core.Exceptions.ResourceNotFoundException")]
[assembly: SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Scope = "type", Target = "Microsoft.Restier.Core.Exceptions.PreconditionRequiredException")]
[assembly: SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Scope = "type", Target = "Microsoft.Restier.Core.PreconditionFailedException")]
[assembly: SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Scope = "type", Target = "Microsoft.Restier.Core.ResourceNotFoundException")]
[assembly: SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Scope = "type", Target = "Microsoft.Restier.Core.PreconditionRequiredException")]
#endregion

#region CA1704 Identifiers spelling
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sourcer", Scope = "type", Target = "Microsoft.Restier.Core.Query.IQueryExpressionSourcer")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sourcer", Scope = "type", Target = "Microsoft.Restier.Providers.EntityFramework.Query.QueryExpressionSourcer")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ef", Scope = "member", Target = "Microsoft.Restier.Providers.EntityFramework.ServiceCollectionExtensions.#AddEfProviderServices`1(Microsoft.Extensions.DependencyInjection.IServiceCollection)")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ef", Scope = "member", Target = "Microsoft.Restier.Providers.EntityFramework.Submit.ChangeSetInitializer.#ConvertToEfValue(System.Type,System.Object)")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Etag", Scope = "member", Target = "Microsoft.Restier.Core.Submit.DataModificationItem.#ApplyEtag(System.Linq.IQueryable)")]
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Etag", Scope = "member", Target = "Microsoft.Restier.Core.Submit.DataModificationItem.#ValidateEtag(System.Linq.IQueryable)")]
#endregion

#region CA1709 Identifiers case
Expand Down Expand Up @@ -162,9 +158,9 @@
[assembly: SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Microsoft.Restier.Core.ApiContext.#.ctor(Microsoft.Restier.Core.ApiConfiguration)")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Microsoft.Restier.Core.QueryableSource.#System.Linq.IQueryProvider.CreateQuery`1(System.Linq.Expressions.Expression)")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly", Scope = "member", Target = "Microsoft.Restier.Core.QueryableSource.#System.Linq.IQueryProvider.CreateQuery(System.Linq.Expressions.Expression)")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Scope = "member", Target = "Microsoft.Restier.Core.Model.ModelContext.#EntitySetTypeMap")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Scope = "member", Target = "Microsoft.Restier.Core.Model.ModelContext.#EntityTypeKeyPropertiesMap")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Scope = "member", Target = "Microsoft.Restier.Core.Operation.OperationContext.#ParametersValue")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Scope = "member", Target = "Microsoft.Restier.Core.Model.ModelContext.#ResourceSetTypeMap")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Scope = "member", Target = "Microsoft.Restier.Core.Model.ModelContext.#ResourceTypeKeyPropertiesMap")]
[assembly: SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Scope = "member", Target = "Microsoft.Restier.Core.Operation.OperationContext.#ParameterValues")]
#endregion

#region CA1801 Unused Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static string GetAuthorizeMethodName(ChangeSetItem item)
operationName = ConventionBasedChangeSetConstants.AuthorizeMethodDataModificationDelete;
}

return operationName + dataModification.EntitySetName;
return operationName + dataModification.ResourceSetName;

default:
throw new InvalidOperationException(string.Format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static string GetMethodName(ChangeSetItem item, string suffix)
operationName = ConventionBasedChangeSetConstants.FilterMethodDataModificationDelete;
}

return operationName + suffix + dataModification.EntitySetName;
return operationName + suffix + dataModification.ResourceSetName;

default:
throw new InvalidOperationException(string.Format(
Expand All @@ -91,7 +91,7 @@ private static object[] GetParameters(ChangeSetItem item)
{
case ChangeSetItemType.DataModification:
DataModificationItem dataModification = (DataModificationItem)item;
return new object[] { dataModification.Entity };
return new object[] { dataModification.Resource };

default:
throw new InvalidOperationException(string.Format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Task ValidateChangeSetItemAsync(
DataModificationItem dataModificationItem = item as DataModificationItem;
if (dataModificationItem != null)
{
object entity = dataModificationItem.Entity;
object entity = dataModificationItem.Resource;

// TODO GitHubIssue#50 : should this PropertyDescriptorCollection be cached?
PropertyDescriptorCollection properties =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ private Task InvokeProcessorMethodAsync(
string methodName = ConventionBasedChangeSetConstants.FilterMethodActionInvocationExecute +
methodNameSuffix + context.OperationName;
object[] parameters = null;
if (context.ParametersValue != null)
if (context.ParameterValues != null)
{
context.ParametersValue.ToArray();
context.ParameterValues.ToArray();
}

MethodInfo method = this.targetType.GetQualifiedMethod(methodName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

using System;

namespace Microsoft.Restier.Core.Exceptions
namespace Microsoft.Restier.Core
{
/// <summary>
/// This exception is used for 412 Precondition Failed response.
/// </summary>
[Serializable]
public class PreconditionFailedException : System.Exception
public class PreconditionFailedException : Exception
{
/// <summary>
/// Initializes a new instance of the PreconditionFailedException class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

using System;

namespace Microsoft.Restier.Core.Exceptions
namespace Microsoft.Restier.Core
{
/// <summary>
/// This exception is used for 428 Precondition required response.
/// </summary>
[Serializable]
public class PreconditionRequiredException : System.Exception
public class PreconditionRequiredException : Exception
{
/// <summary>
/// Initializes a new instance of the PreconditionRequiredException class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

using System;

namespace Microsoft.Restier.Core.Exceptions
namespace Microsoft.Restier.Core
{
/// <summary>
/// This exception is used for 404 Not found response.
/// </summary>
[Serializable]
public class ResourceNotFoundException : System.Exception
public class ResourceNotFoundException : Exception
{
/// <summary>
/// Initializes a new instance of the ResourceNotFoundException class.
Expand Down
8 changes: 8 additions & 0 deletions src/Microsoft.Restier.Core/Microsoft.Restier.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<Compile Include="..\Shared\Ensure.cs">
<Link>Shared\Ensure.cs</Link>
</Compile>
<Compile Include="..\Shared\EnumerableExtensions.cs">
<Link>Shared\EnumerableExtensions.cs</Link>
</Compile>
<Compile Include="..\Shared\ExpressionHelperMethods.cs">
<Link>Shared\ExpressionHelperMethods.cs</Link>
</Compile>
Expand All @@ -49,6 +52,11 @@
</Compile>
<Compile Include="..\Shared\TypeExtensions.cs">
<Link>Shared\TypeExtensions.cs</Link>
</Compile>
<Compile Include="..\Shared\SharedResources\SharedResources.Core.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>SharedResources.resx</DependentUpon>
</Compile>
<Compile Include="ApiConfiguratorAttributes.cs" />
<Compile Include="Conventions\ConventionBasedOperationProcessor.cs" />
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.Restier.Core/Model/ModelContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ public ModelContext(ApiContext apiContext)
}

/// <summary>
/// Gets or sets Entity set and entity type map dictionary, it will be used by publisher for model build.
/// Gets or sets resource set and resource type map dictionary, it will be used by publisher for model build.
/// </summary>
public IDictionary<string, Type> EntitySetTypeMap { get; set; }
public IDictionary<string, Type> ResourceSetTypeMap { get; set; }

/// <summary>
/// Gets or sets entity type and its key properties map dictionary, and used by publisher for model build.
/// Gets or sets resource type and its key properties map dictionary, and used by publisher for model build.
/// This is useful when key properties does not have key attribute
/// or follow Web Api OData key property naming convention.
/// Otherwise, this collection is not needed.
/// </summary>
public IDictionary<Type, ICollection<PropertyInfo>> EntityTypeKeyPropertiesMap { get; set; }
public IDictionary<Type, ICollection<PropertyInfo>> ResourceTypeKeyPropertiesMap { get; set; }
}
}
15 changes: 8 additions & 7 deletions src/Microsoft.Restier.Core/Operation/OperationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -16,8 +17,8 @@ public class OperationContext : InvocationContext
private readonly string operationName;
private readonly Func<string, object> getParameterValueFunc;
private readonly bool isFunction;
private readonly IQueryable bindingParameterValue;
private ICollection<object> parametersValue;
private readonly IEnumerable bindingParameterValue;
private ICollection<object> parameterValues;

/// <summary>
/// Initializes a new instance of the <see cref="OperationContext" /> class.
Expand All @@ -42,7 +43,7 @@ public OperationContext(
Func<string, object> getParameterValueFunc,
string operationName,
bool isFunction,
IQueryable bindingParameterValue)
IEnumerable bindingParameterValue)
: base(apiContext)
{
this.getParameterValueFunc = getParameterValueFunc;
Expand Down Expand Up @@ -88,7 +89,7 @@ public bool IsFunction
/// Gets the queryable for binding parameter value,
/// and if it is function/action import, the value will be null.
/// </summary>
public IQueryable BindingParameterValue
public IEnumerable BindingParameterValue
{
get
{
Expand All @@ -100,16 +101,16 @@ public IQueryable BindingParameterValue
/// Gets or sets the parameters value array used by method,
/// It is only set after parameters are prepared.
/// </summary>
public ICollection<object> ParametersValue
public ICollection<object> ParameterValues
{
get
{
return this.parametersValue;
return this.parameterValues;
}

set
{
this.parametersValue = value;
this.parameterValues = value;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/Microsoft.Restier.Core/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Microsoft.Restier.Core/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,7 @@
<data name="ResourceNotFound" xml:space="preserve">
<value>The request resource is not found.</value>
</data>
<data name="PreconditionCheckFailed" xml:space="preserve">
<value>The precondition check for request {0} on resource {1} is failed.</value>
</data>
</root>
1 change: 0 additions & 1 deletion src/Microsoft.Restier.Core/Query/DefaultQueryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.OData.Edm;
using Microsoft.Restier.Core.Exceptions;
using Microsoft.Restier.Core.Properties;

namespace Microsoft.Restier.Core.Query
Expand Down
Loading

0 comments on commit d8c8e1a

Please sign in to comment.