зеркало из
1
0
Форкнуть 0
This commit is contained in:
praveensri 2021-04-08 21:45:26 -07:00
Родитель ef57c274f6
Коммит 41451aad4c
14 изменённых файлов: 402 добавлений и 165 удалений

Просмотреть файл

@ -18,6 +18,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{45DEA270-AE97-412B-8DF6-6DEEA570C01F}"
ProjectSection(SolutionItems) = preProject
azure-pipelines.yml = azure-pipelines.yml
src.ruleset = src.ruleset
stylecop.json = stylecop.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{2108829F-8E0A-4F6D-BF07-E4BB34193D1E}"

127
src.ruleset Normal file
Просмотреть файл

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="WebJobs SDK" Description="This rule set contains the rules that applies to sources" ToolsVersion="15.0">
<IncludeAll Action="Error" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1006" Action="None" />
<Rule Id="CA1020" Action="None" />
<Rule Id="CA1024" Action="None" />
<Rule Id="CA1026" Action="None" />
<Rule Id="CA1031" Action="None" />
<Rule Id="CA1033" Action="None" />
<Rule Id="CA1062" Action="None" />
<Rule Id="CA1303" Action="None" />
<Rule Id="CA1305" Action="None" />
<Rule Id="CA1307" Action="None" />
<Rule Id="CA1308" Action="None" />
<Rule Id="CA1506" Action="None" />
<Rule Id="CA1726" Action="None" />
<Rule Id="CA1800" Action="None" />
<Rule Id="CA2204" Action="None" />
<Rule Id="CA2210" Action="None" />
<Rule Id="CA2243" Action="None" />
<Rule Id="CA904" Action="None" />
<Rule Id="CA905" Action="None" />
<Rule Id="CA908" Action="None" />
<Rule Id="CS0618" Action="None" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA0001" Action="None" />
<Rule Id="SA1005" Action="None" />
<Rule Id="SA1101" Action="None" />
<Rule Id="SA1116" Action="None" />
<Rule Id="SA1117" Action="None" />
<Rule Id="SA1127" Action="None" />
<Rule Id="SA1128" Action="None" />
<Rule Id="SA1139" Action="None" />
<Rule Id="SA1202" Action="None" />
<Rule Id="SA1204" Action="None" />
<Rule Id="SA1308" Action="None" />
<Rule Id="SA1309" Action="None" />
<Rule Id="SA1314" Action="None" />
<Rule Id="SA1402" Action="None" />
<Rule Id="SA1404" Action="None" />
<Rule Id="SA1405" Action="None" />
<Rule Id="SA1413" Action="None" />
<Rule Id="SA1502" Action="None" />
<Rule Id="SA1512" Action="None" />
<Rule Id="SA1513" Action="None" />
<Rule Id="SA1611" Action="None" />
<Rule Id="SA1615" Action="None" />
<Rule Id="SA1618" Action="None" />
<Rule Id="SA1028" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1009" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1649" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1623" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1515" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1401" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1516" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1400" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1507" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1124" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1614" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1616" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1617" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1622" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1311" Action="None" />
<!-- Re-enable this -->
<Rule Id="SA1134" Action="None" />
<Rule Id="SA1201" Action="None" />
<Rule Id="SA1121" Action="None" />
<Rule Id="SA1111" Action="None" />
<Rule Id="SA1118" Action="None" />
<Rule Id="SA1003" Action="None" />
<Rule Id="SA1013" Action="None" />
<Rule Id="SA1208" Action="None" />
<Rule Id="SA1210" Action="None" />
<Rule Id="SA1500" Action="None" />
<Rule Id="SA1012" Action="None" />
<Rule Id="SA1122" Action="None" />
<Rule Id="SA1129" Action="None" />
<Rule Id="SA1312" Action="None" />
<Rule Id="SA1137" Action="None" />
<Rule Id="SA1130" Action="None" />
<Rule Id="SA1514" Action="None" />
<Rule Id="SA1505" Action="None" />
<Rule Id="SA1119" Action="None" />
<Rule Id="SA1125" Action="None" />
<Rule Id="SA1206" Action="None" />
<Rule Id="SA1300" Action="None" />
<Rule Id="SA1509" Action="None" />
<Rule Id="SA1008" Action="None" />
<Rule Id="SA1606" Action="None" />
<Rule Id="SA1107" Action="None" />
<Rule Id="SA1504" Action="None" />
<Rule Id="SA1642" Action="None" />
<Rule Id="SA1407" Action="None" />
<Rule Id="SA1624" Action="None" />
<Rule Id="SA1214" Action="None" />
<Rule Id="SA1100" Action="None" />
<Rule Id="SA1501" Action="None" />
<Rule Id="SA1108" Action="None" />
<Rule Id="SA1203" Action="None" />
<Rule Id="SA1002" Action="None" />
</Rules>
<Rules AnalyzerId="xunit.analyzers" RuleNamespace="xunit.analyzers">
<Rule Id="xUnit1013" Action="None" />
<Rule Id="xUnit2000" Action="None" />
<Rule Id="xUnit2009" Action="None" />
<Rule Id="xUnit2002" Action="None" />
<Rule Id="xUnit2003" Action="None" />
<Rule Id="xUnit2004" Action="None" />
<Rule Id="xUnit1004" Action="None" />
</Rules>
</RuleSet>

Просмотреть файл

@ -1,9 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\sign.snk</AssemblyOriginatorKeyFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>..\..\src.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<None Update="tools\add-extension.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(SolutionDir)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,4 +1,6 @@

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.Common
{
using System;
@ -13,6 +15,7 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.Common
/// To hex color.
/// </summary>
/// <param name="color">Color</param>
/// <returns>unit.</returns>
public static uint ToHexColor(this Color color)
{
return (uint)((color.A << 24) | (color.R << 16) |

Просмотреть файл

@ -0,0 +1,112 @@
function add-extension
{
param(
[ValidateScript({
if( -Not ($_ | Test-Path) ){
throw "Extension folder does not exist.. check Path parameter."
}
return $true
})]
[System.IO.FileInfo]$Path,
[String]
$Name
)
process
{
$extensionPath=$Path
$extensionName = $Name
$extensionNameServiceProvider = $extensionName+"ServiceProvider"
write-host "Nuget extension path is $extensionPath"
$extensionNameServiceProvider = $extensionName+"ServiceProvider"
$userprofile = [environment]::GetFolderPath('USERPROFILE')
$dll = Join-Path -Path $extensionPath -ChildPath "netcoreapp3.1"
$childPath = "Microsoft.Azure.Workflows.ServiceProvider.Extensions." + $extensionName + ".dll"
$dll = Join-Path -Path $dll -ChildPath $childPath
if ( Test-Path -Path $dll )
{
write-host "Extension dll path is $dll"
}
else
{
throw "Extension dll path does not exist $dll"
}
$extensionModulePath = Join-Path -Path $userprofile -ChildPath ".azure-functions-core-tools"
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "Functions"
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "ExtensionBundles"
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "Microsoft.Azure.Functions.ExtensionBundle.Workflows"
if ( Test-Path -Path $extensionModulePath )
{
write-host "Extension bundle module path is $extensionModulePath"
}
else
{
throw "Extension bundle module path does not exist $extensionModulePath"
}
$latest = Get-ChildItem -Path $extensionModulePath | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$latest.name
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath $latest.name
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "bin"
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "extensions.json"
if ( Test-Path -Path $extensionModulePath )
{
write-host "EXTENSION PATH is $extensionModulePath and dll Path is $dll"
}
else
{
throw "The extensions.json in extension bundle does not exist $extensionModulePath"
}
$fullAssemlyName = [System.Reflection.AssemblyName]::GetAssemblyName($dll).FullName
try
{
# Kill all the existing func.exe else modeule extension cannot be modified.
taskkill /IM "func.exe" /F
}
catch
{
write-host "func.exe not found"
}
$extensionFullName = "Microsoft.Azure.Workflows.ServiceProvider.Extensions." + $extensionName
$startupClass = $extensionFullName + "." + $extensionName + "Startup"
# 1. Add Nuget package to existing project
dotnet add package $extensionFullName --version 1.0.0 --source $extensionPath
# 2. Update extensions.json under extension module
$typeFullName = $startupClass + ", " + $fullAssemlyName
$newNode = [pscustomobject] @{
name = $extensionNameServiceProvider
typeName = $typeFullName}
$jsonContent = Get-Content $extensionModulePath -raw | ConvertFrom-Json
if ( ![bool]($jsonContent.extensions.name -match $extensionNameServiceProvider))
{
$jsonContent.extensions += $newNode
}
else
{
$jsonContent.extensions | % {if($_.name -eq $extensionNameServiceProvider){$_.typeName=$typeFullName}}
}
$jsonContent | ConvertTo-Json -depth 32| set-content $extensionModulePath
# 3. update dll in extension module.
$spl = Split-Path $extensionModulePath
Copy-Item $dll -Destination $spl
Write-host "Extension $extensionName is successfully added. "
}
}
# execute the above function here.
add-extension $args[0] $args[1]

Просмотреть файл

@ -3,10 +3,17 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\sign.snk</AssemblyOriginatorKeyFile>
<CodeAnalysisRuleSet>..\..\src.ruleset</CodeAnalysisRuleSet>
<NoWarn>$(NoWarn);NU5104</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.Workflows.WebJobs.Extension" Version="*-*" />
</ItemGroup>
@ -18,9 +25,16 @@
<None Update="icon.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="tools\deploy.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(SolutionDir)stylecop.json" Link="stylecop.json" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Update="C:\Users\psrivas\.nuget\packages\microsoft.azure.workflows.webjobs.extension\1.0.1.3-preview\build\Microsoft.Azure.Workflows.BuildTasks.DebugSymbolGenerator.runtimeconfig.json">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</AdditionalFiles>
</ItemGroup>
</Project>

Просмотреть файл

@ -42,7 +42,7 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
private readonly InsensitiveDictionary<ServiceOperation> apiOperationsList;
/// <summary>
/// Constructor for Service operation provider.
/// Initializes a new instance of the <see cref="CosmosDBServiceOperationProvider"/> class.
/// </summary>
public CosmosDBServiceOperationProvider()
{
@ -56,16 +56,16 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
this.serviceOperationsList.AddRange(new List<ServiceOperation>
{
{ this.GetReceiveDocumentServiceOperation().CloneWithManifest(this.GetServiceOperationManifest()) }
{ this.GetReceiveDocumentServiceOperation().CloneWithManifest(this.GetServiceOperationManifest()) },
});
}
/// <summary>
/// Get binding connection information, needed for Azure function triggers.
/// </summary>
/// <param name="operationId"></param>
/// <param name="connectionParameters"></param>
/// <returns></returns>
/// <param name="operationId">Operation id.</param>
/// <param name="connectionParameters">Connection parameters.</param>
/// <returns>string.</returns>
public string GetBindingConnectionInformation(string operationId, InsensitiveDictionary<JToken> connectionParameters)
{
return ServiceOperationsProviderUtilities
@ -77,10 +77,49 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
.ToValue<string>();
}
/// <summary>
/// If the registration of service provider is successful then this should resturn the trigger type.
/// </summary>
/// <returns>string.</returns>
public string GetFunctionTriggerType()
{
return "cosmosDBTrigger";
}
/// <summary>
/// Get operations.
/// </summary>
/// <param name="expandManifest">Expand manifest generation.</param>
/// <returns>Service operation list.</returns>
public IEnumerable<ServiceOperation> GetOperations(bool expandManifest)
{
return expandManifest ? this.serviceOperationsList : this.GetApiOperations();
}
/// <summary>
/// Get service operation.
/// </summary>
/// <returns>Service operation api.</returns>
public ServiceOperationApi GetService()
{
return this.GetServiceOperationApi();
}
/// <summary>
/// The CosmosDB service provider is only trigger based connector hence skipped the implementation.
/// </summary>
/// <param name="operationId">Operation Id.</param>
/// <param name="connectionParameters">Connection parameters.</param>
/// <param name="serviceOperationRequest">Service operation request.</param>
/// <returns>Service operation response.</returns>
public Task<ServiceOperationResponse> InvokeOperation(string operationId, InsensitiveDictionary<JToken> connectionParameters, ServiceOperationRequest serviceOperationRequest)
{
throw new NotImplementedException();
}
/// <summary>
/// Implements the Swagger schema defining the input , output and scope.
/// </summary>
/// <returns></returns>
private ServiceOperationManifest GetServiceOperationManifest()
{
return new ServiceOperationManifest
@ -181,7 +220,7 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
Required = new string[]
{
"databaseName",
"collectionName"
"collectionName",
},
},
Connector = this.GetServiceOperationApi(),
@ -193,24 +232,6 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
};
}
/// <summary>
/// If the registration of service provider is successful then this should resturn the trigger type.
/// </summary>
/// <returns></returns>
public string GetFunctionTriggerType()
{
return "cosmosDBTrigger";
}
/// <summary>
/// Get operations.
/// </summary>
/// <param name="expandManifest">Expand manifest generation.</param>
public IEnumerable<ServiceOperation> GetOperations(bool expandManifest)
{
return expandManifest ? serviceOperationsList : GetApiOperations();
}
/// <summary>
/// Gets the api operations.
/// </summary>
@ -219,26 +240,6 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
return this.apiOperationsList.Values;
}
/// <summary>
/// Get service operation.
/// </summary>
public ServiceOperationApi GetService()
{
return this.GetServiceOperationApi();
}
/// <summary>
/// The CosmosDB service provider is only trigger based connector hence skipped the implementation.
/// </summary>
/// <param name="operationId"></param>
/// <param name="connectionParameters"></param>
/// <param name="serviceOperationRequest"></param>
/// <returns></returns>
public Task<ServiceOperationResponse> InvokeOperation(string operationId, InsensitiveDictionary<JToken> connectionParameters, ServiceOperationRequest serviceOperationRequest)
{
throw new NotImplementedException();
}
/// <summary>
/// The receive documents operation which define the connection and top level design.
/// </summary>
@ -294,11 +295,11 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
Constraints = new Constraints
{
Required = "true",
}
}
}
}
}
},
},
},
},
},
};
}
}

Просмотреть файл

@ -18,38 +18,41 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
public class CosmosDBServiceProvider : IExtensionConfigProvider
{
/// <summary>
/// Register the service provider.
/// Initializes a new instance of the <see cref="CosmosDBServiceProvider"/> class.
/// </summary>
/// <param name="serviceOperationsProvider"></param>
/// <param name="operationsProvider"></param>
public CosmosDBServiceProvider(ServiceOperationsProvider serviceOperationsProvider,
/// <param name="serviceOperationsProvider">Service operations provider.</param>
/// <param name="operationsProvider">Operation provider.</param>
public CosmosDBServiceProvider(
ServiceOperationsProvider serviceOperationsProvider,
CosmosDBServiceOperationProvider operationsProvider)
{
serviceOperationsProvider.RegisterService(serviceName: CosmosDBServiceOperationProvider.ServiceName, serviceOperationsProviderId: CosmosDBServiceOperationProvider.ServiceId, serviceOperationsProviderInstance: operationsProvider);
}
/// <summary>
/// You can add any custom implementation in Initialize method.
/// </summary>
/// <param name="context"></param>
public void Initialize(ExtensionConfigContext context)
{
context.AddConverter<IReadOnlyList<Document>, JObject[]>(ConvertDocumentToJObject);
}
/// <summary>
/// Cosmos DB trigger runtime provides the array of Document. In this method we convert it to generic JObject array.
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
/// <param name="data">Data.</param>
/// <returns>JObject array.</returns>
public static JObject[] ConvertDocumentToJObject(IReadOnlyList<Document> data)
{
List<JObject> jobjects = new List<JObject>();
foreach (var doc in data)
{
jobjects.Add(item: (JObject)doc.ToJToken());
}
return jobjects.ToArray();
}
/// <summary>
/// You can add any custom implementation in Initialize method.
/// </summary>
/// <param name="context">Context.</param>
public void Initialize(ExtensionConfigContext context)
{
context.AddConverter<IReadOnlyList<Document>, JObject[]>(ConvertDocumentToJObject);
}
}
}

Просмотреть файл

@ -17,7 +17,7 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB
/// <summary>
/// The Configure method is invoked as initialization of the extension.
/// </summary>
/// <param name="builder"></param>
/// <param name="builder">Builder.</param>
public void Configure(IWebJobsBuilder builder)
{
builder.AddExtension<CosmosDBServiceProvider>();

Просмотреть файл

@ -1,63 +0,0 @@
$extensionPath=Split-Path -parent $PSCommandPath
$extensionPath = (get-item $extensionPath).parent.parent.FullName
write-host "Nuget extension path is $extensionPath"
$extensionName = "CosmosDB"
$extensionNameServiceProvider = $extensionName+"ServiceProvider"
$userprofile = [environment]::GetFolderPath('USERPROFILE')
$dll = Join-Path -Path $extensionPath -ChildPath "netcoreapp3.1"
$dll = Join-Path -Path $dll -ChildPath "Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.dll"
$extensionModulePath = Join-Path -Path $userprofile -ChildPath ".azure-functions-core-tools"
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "Functions"
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "ExtensionBundles"
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "Microsoft.Azure.Functions.ExtensionBundle.Workflows"
$latest = Get-ChildItem -Path $extensionModulePath | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$latest.name
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath $latest.name
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "bin"
$extensionModulePath = Join-Path -Path $extensionModulePath -ChildPath "extensions.json"
write-host "EXTENSION PATH is $extensionModulePath and dll Path is $dll"
$fullAssemlyName = [System.Reflection.AssemblyName]::GetAssemblyName($dll).FullName
try
{
# Kill all the existing func.exe else modeule extension cannot be modified.
taskkill /IM "func.exe" /F
}
catch
{
write-host "func.exe not found"
}
# 1. Add Nuget package to existing project
dotnet add package "Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB" --version 1.0.0 --source $extensionPath
# 2. Update extensions.json under extension module
$typeFullName = "Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.CosmosDBStartup, $fullAssemlyName"
$newNode = [pscustomobject] @{
name = $extensionNameServiceProvider
typeName = $typeFullName}
$jsonContent = Get-Content $extensionModulePath -raw | ConvertFrom-Json
if ( ![bool]($jsonContent.extensions.name -match $extensionNameServiceProvider))
{
$jsonContent.extensions += $newNode
}
else
{
$jsonContent.extensions | % {if($_.name -eq $extensionNameServiceProvider){$_.typeName=$typeFullName}}
}
$jsonContent | ConvertTo-Json -depth 32| set-content $extensionModulePath
# 3. update dll in extension module.
$spl = Split-Path $extensionModulePath
Copy-Item $dll -Destination $spl
Write-host "Successfully added extension.. "

Просмотреть файл

@ -8,7 +8,17 @@
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"companyName": "PlaceholderCompany"
"companyName": ".NET Foundation",
"copyrightText": "Copyright (c) .NET Foundation. All rights reserved.\r\nLicensed under the MIT License. See License.txt in the project root for license information.",
"xmlHeader": false,
"documentInterfaces": false,
"documentInternalElements": false,
"documentExposedElements": false,
"documentPrivateElements": false,
"documentPrivateFields": false
},
"orderingRules": {
"usingDirectivesPlacement": "insideNamespace"
}
}
}

Просмотреть файл

@ -32,11 +32,11 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.Tests
/// <summary>
/// CosmsoDB EndToEnd Test.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact]
public async Task CosmosDBEndToEnd()
{
using (var host = await this.StartHostAsync())
{
using var host = await this.StartHostAsync();
var alllogs = this.loggerProvider.GetAllLogMessages();
var logsList = alllogs.ToList();
Assert.True(logsList.Where(item => item.FormattedMessage.ContainsInsensitively("Job host started")).Count() >= 1);
@ -51,7 +51,6 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.Tests
Assert.Single(operations.ToList());
Assert.Equal("receiveDocument", services.GetOperations(false).FirstOrDefault().Name);
}
}
/// <summary>
/// Start web host.
@ -59,8 +58,10 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.Tests
/// <returns>IHost task.</returns>
private async Task<IHost> StartHostAsync()
{
var localSettings = new Dictionary<string, string>();
localSettings["AzureWebJobsStorage"] = "UseDevelopmentStorage=true";
var localSettings = new Dictionary<string, string>
{
["AzureWebJobsStorage"] = "UseDevelopmentStorage=true",
};
var host = new HostBuilder()
.ConfigureWebJobs(builder =>
@ -77,9 +78,11 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.Tests
})
.ConfigureAppConfiguration(c =>
{
c.AddInMemoryCollection(new[] {
c.AddInMemoryCollection(new[]
{
new KeyValuePair<string, string>("AzureWebJobsStorage", "UseDevelopmentStorage=true"),
new KeyValuePair<string, string>("FUNCTIONS_WORKER_RUNTIME","dotnet"), });
new KeyValuePair<string, string>("FUNCTIONS_WORKER_RUNTIME", "dotnet"),
});
})
.Build();

Просмотреть файл

@ -64,8 +64,8 @@ namespace Microsoft.Azure.Workflows.ServiceProvider.Extensions.CosmosDB.Tests
var operations = new CosmosDBServiceOperationProvider();
var apiCapability = operations.GetService().Properties.Capabilities as ApiCapability[];
Assert.Equal(apiCapability.Length, 1);
Assert.Equal(apiCapability[0], ApiCapability.Triggers);
Assert.Single(apiCapability);
Assert.Equal(ApiCapability.Triggers, apiCapability[0]);
this.outputLogger.WriteLine("Connector supports only trigger");
}
}

Просмотреть файл

@ -2,6 +2,9 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\sign.snk</AssemblyOriginatorKeyFile>
<CodeAnalysisRuleSet>..\..\..\src.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
@ -27,4 +30,8 @@
<ProjectReference Include="..\..\..\src\Common\Microsoft.Azure.Workflows.ServiceProvider.Extensions.Common.csproj" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(SolutionDir)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>