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

Enable Capabilities Vocabulary Configuration #9

Merged
merged 29 commits into from
Aug 30, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bfbdc3c
Autogenerated vocabulary builders in progress.
g2mula Jun 16, 2020
2817fe7
Bsl and xml fixes.
g2mula Jun 16, 2020
c487701
Autogeneration in progress.
g2mula Jun 17, 2020
dce1da3
Autogeneration in progress.
g2mula Jun 17, 2020
d2cae7b
Autogeneration in progress.
g2mula Jun 17, 2020
d118f65
Autogeneration namespacing.
g2mula Jun 17, 2020
4bcbf06
Auto generated more progress.
g2mula Jun 17, 2020
9849041
Generating base types.
g2mula Jun 17, 2020
308bcd0
bsl and xml.
g2mula Jun 17, 2020
87701d7
Bug fixes.
g2mula Jun 18, 2020
3c7a2ee
Some reorganisation.
g2mula Jun 18, 2020
40b69e9
xml doc fix.
g2mula Jun 18, 2020
e59dd70
Bug fixes, tests for usage and bsl and xml changes.
g2mula Jun 18, 2020
156a2f6
Fixes.
g2mula Jun 18, 2020
9a75814
Prefer UnionWiith when updating HashSet with Collection.
g2mula Jun 22, 2020
cc50a0e
Test asserting vocabulary annotations are not added by the modelbuild…
g2mula Jul 8, 2020
f80fb68
Sort usings, set copyright.
g2mula Jul 8, 2020
bcd70ea
Use HasX prefix for collection properties.
g2mula Jul 8, 2020
0a7b173
Sort usings, add copyright.
g2mula Jul 8, 2020
bd9ea4a
Renaming Vocabulary folder to Vocabularies.
g2mula Jul 8, 2020
ab9c096
Update Public bsl after changes.
g2mula Jul 8, 2020
e4a6027
Adding fluent complex property configuration.
g2mula Jul 21, 2020
1ebed9b
Updated OData version to 7.7.0
g2mula Aug 17, 2020
07d7c28
Nuget package reference from template + Complex type configuration do…
g2mula Aug 17, 2020
4032a95
Scopes shortcut + bsl update + odata lib update.
g2mula Aug 17, 2020
3e6a045
Remove excess enum whitespace.
g2mula Aug 26, 2020
c99d81a
Vocabulary TermName moved from constructor parameter to abstract prop…
g2mula Aug 26, 2020
9687aff
Enum values now output to annotations.
g2mula Aug 26, 2020
ea6775d
Support for primitive property settings (converting to string)
g2mula Aug 26, 2020
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
Expand Up @@ -96,6 +96,11 @@ public IEnumerable<NavigationPropertyBindingConfiguration> Bindings
/// </summary>
public string Name { get; private set; }

/// <summary>
/// Vocabulary builders to annotate this <see cref="NavigationSourceConfiguration"/>
/// </summary>
public Dictionary<Type, VocabularyTermConfiguration> VocabularyTermConfigurations { get; } = new Dictionary<Type, VocabularyTermConfiguration>();

/// <summary>
/// Gets the navigation source URL.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static IDictionary<string, EdmNavigationSource> GetNavigationSourceMap(t
private static void AddNavigationBindings(EdmTypeMap edmMap,
NavigationSourceConfiguration navigationSourceConfiguration,
EdmNavigationSource navigationSource,
// NavigationSourceLinkBuilderAnnotation linkBuilder,
// NavigationSourceLinkBuilderAnnotation linkBuilder,
Dictionary<string, EdmNavigationSource> edmNavigationSourceMap)
{
foreach (var binding in navigationSourceConfiguration.Bindings)
Expand Down Expand Up @@ -332,6 +332,7 @@ private static void AddOperations(this EdmModel model, IEnumerable<OperationConf
}

model.AddElement(operation);
model.SetVocabularyConfigurationAnnotations(operation, operationConfiguration);
}
}

Expand Down Expand Up @@ -655,6 +656,7 @@ private static void AddCapabilitiesVocabularyAnnotations(this EdmModel model, IE

foreach (NavigationSourceAndAnnotations source in navigationSources)
{
model.SetVocabularyConfigurationAnnotations(source.NavigationSource, source.Configuration);
IEdmEntitySet entitySet = source.NavigationSource as IEdmEntitySet;
if (entitySet == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>SRResources.resx</DependentUpon>
</Compile>
<Compile Update="Vocabulary\VocabularyTermConfigurationExtensions.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>VocabularyTermConfigurationExtensions.tt</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
Expand All @@ -41,5 +46,16 @@
<LastGenOutput>SRResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<None Update="Vocabulary\VocabularyTermConfigurationExtensions.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>VocabularyTermConfigurationExtensions.cs</LastGenOutput>
</None>
</ItemGroup>

<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>

</Project>
2,158 changes: 2,158 additions & 0 deletions src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public string Namespace
/// </summary>
public IEnumerable<string> EntitySetPath { get; internal set; }

/// <summary>
/// Vocabulary builders to annotate this <see cref="OperationConfiguration"/>
/// </summary>
public Dictionary<Type, VocabularyTermConfiguration> VocabularyTermConfigurations { get; } = new Dictionary<Type, VocabularyTermConfiguration>();

/// <summary>
/// Get the bindingParameter.
/// <remarks>Null means the operation has no bindingParameter.</remarks>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// This is an auto generated file. Please run the template to modify it.

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;

namespace Microsoft.OData.ModelBuilder.Capabilities.V1
{
/// <summary>
/// List of acceptable compression methods for ($batch) requests, e.g. gzip
/// </summary>
public partial class AcceptableEncodingsConfiguration : VocabularyTermConfiguration
{
private readonly HashSet<string> _acceptableEncodings = new HashSet<string>();

/// <summary>
/// Creates a new instance of <see cref="AcceptableEncodingsConfiguration"/>
/// </summary>
public AcceptableEncodingsConfiguration()
: base("Org.OData.Capabilities.V1.AcceptableEncodings")
{
}

/// <summary>
/// List of acceptable compression methods for ($batch) requests, e.g. gzip
/// </summary>
/// <param name="acceptableEncodings">The value(s) to set</param>
/// <returns><see cref="AcceptableEncodingsConfiguration"/></returns>
public AcceptableEncodingsConfiguration AddAcceptableEncodings(params string[] acceptableEncodings)
{
_acceptableEncodings.UnionWith(acceptableEncodings);
return this;
}

/// <inheritdoc/>
public override IEdmExpression ToEdmExpression()
{
var properties = new List<IEdmPropertyConstructor>();

if (_acceptableEncodings.Any())
{
var collection = _acceptableEncodings.Select(item => item.ToEdmExpression()).Where(item => item != null);
if (collection.Any())
{
properties.Add(new EdmPropertyConstructor("AcceptableEncodings", new EdmCollectionExpression(collection)));
}
}

if (!properties.Any())
{
return null;
}

return new EdmRecordExpression(properties);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// This is an auto generated file. Please run the template to modify it.

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;

namespace Microsoft.OData.ModelBuilder.Capabilities.V1
{
/// <summary>
/// Supports annotation values within system query options
/// </summary>
public partial class AnnotationValuesInQuerySupportedConfiguration : VocabularyTermConfiguration
{
private bool? _annotationValuesInQuerySupported;

/// <summary>
/// Creates a new instance of <see cref="AnnotationValuesInQuerySupportedConfiguration"/>
/// </summary>
public AnnotationValuesInQuerySupportedConfiguration()
: base("Org.OData.Capabilities.V1.AnnotationValuesInQuerySupported")
{
}

/// <summary>
/// Supports annotation values within system query options
/// </summary>
/// <param name="annotationValuesInQuerySupported">The value to set</param>
/// <returns><see cref="AnnotationValuesInQuerySupportedConfiguration"/></returns>
public AnnotationValuesInQuerySupportedConfiguration IsAnnotationValuesInQuerySupported(bool annotationValuesInQuerySupported)
{
_annotationValuesInQuerySupported = annotationValuesInQuerySupported;
return this;
}

/// <inheritdoc/>
public override IEdmExpression ToEdmExpression()
{
var properties = new List<IEdmPropertyConstructor>();

if (_annotationValuesInQuerySupported.HasValue)
{
properties.Add(new EdmPropertyConstructor("AnnotationValuesInQuerySupported", new EdmBooleanConstant(_annotationValuesInQuerySupported.Value)));
}

if (!properties.Any())
{
return null;
}

return new EdmRecordExpression(properties);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// This is an auto generated file. Please run the template to modify it.

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;

namespace Microsoft.OData.ModelBuilder.Capabilities.V1
{
/// <summary>
/// Service supports the asynchronous request preference
/// </summary>
public partial class AsynchronousRequestsSupportedConfiguration : VocabularyTermConfiguration
{
private bool? _asynchronousRequestsSupported;

/// <summary>
/// Creates a new instance of <see cref="AsynchronousRequestsSupportedConfiguration"/>
/// </summary>
public AsynchronousRequestsSupportedConfiguration()
: base("Org.OData.Capabilities.V1.AsynchronousRequestsSupported")
{
}

/// <summary>
/// Service supports the asynchronous request preference
/// </summary>
/// <param name="asynchronousRequestsSupported">The value to set</param>
/// <returns><see cref="AsynchronousRequestsSupportedConfiguration"/></returns>
public AsynchronousRequestsSupportedConfiguration IsAsynchronousRequestsSupported(bool asynchronousRequestsSupported)
{
_asynchronousRequestsSupported = asynchronousRequestsSupported;
return this;
}

/// <inheritdoc/>
public override IEdmExpression ToEdmExpression()
{
var properties = new List<IEdmPropertyConstructor>();

if (_asynchronousRequestsSupported.HasValue)
{
properties.Add(new EdmPropertyConstructor("AsynchronousRequestsSupported", new EdmBooleanConstant(_asynchronousRequestsSupported.Value)));
}

if (!properties.Any())
{
return null;
}

return new EdmRecordExpression(properties);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// This is an auto generated file. Please run the template to modify it.

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;

namespace Microsoft.OData.ModelBuilder.Capabilities.V1
{
/// <summary>
/// Service supports the continue on error preference. Supports $batch requests. Services that apply the BatchContinueOnErrorSupported term should also specify the ContinueOnErrorSupported property from the BatchSupport term.
/// </summary>
public partial class BatchContinueOnErrorSupportedConfiguration : VocabularyTermConfiguration
{
private bool? _batchContinueOnErrorSupported;

/// <summary>
/// Creates a new instance of <see cref="BatchContinueOnErrorSupportedConfiguration"/>
/// </summary>
public BatchContinueOnErrorSupportedConfiguration()
: base("Org.OData.Capabilities.V1.BatchContinueOnErrorSupported")
{
}

/// <summary>
/// Service supports the continue on error preference. Supports $batch requests. Services that apply the BatchContinueOnErrorSupported term should also specify the ContinueOnErrorSupported property from the BatchSupport term.
/// </summary>
/// <param name="batchContinueOnErrorSupported">The value to set</param>
/// <returns><see cref="BatchContinueOnErrorSupportedConfiguration"/></returns>
public BatchContinueOnErrorSupportedConfiguration IsBatchContinueOnErrorSupported(bool batchContinueOnErrorSupported)
{
_batchContinueOnErrorSupported = batchContinueOnErrorSupported;
return this;
}

/// <inheritdoc/>
public override IEdmExpression ToEdmExpression()
{
var properties = new List<IEdmPropertyConstructor>();

if (_batchContinueOnErrorSupported.HasValue)
{
properties.Add(new EdmPropertyConstructor("BatchContinueOnErrorSupported", new EdmBooleanConstant(_batchContinueOnErrorSupported.Value)));
}

if (!properties.Any())
{
return null;
}

return new EdmRecordExpression(properties);
}
}
}
Loading