Skip to content

Commit

Permalink
Upgrade to .NET 6 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachabruttin authored Mar 25, 2022
1 parent 48c19d8 commit e0e333d
Show file tree
Hide file tree
Showing 368 changed files with 14,880 additions and 14,002 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build CosmosDbExplorer
on:
push:
branches:
- master
- "**"
pull_request:
branches:
- master
Expand All @@ -27,19 +27,37 @@ jobs:
- name: Setup MSBuild.exe
uses: microsoft/[email protected]

- name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.7.x'
# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'

- name: Restore NuGet Packages
run: nuget restore $env:Solution_Name
- name: Restore dependencies
run: dotnet restore $env:Solution_Name

- name: Build Application
run: msbuild $env:Solution_Name /p:Configuration=Release
run: dotnet build $env:Solution_Name --no-restore --configuration Release #/p:Version=0.9.3.12

- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: CosmosDbExplorer
path: src\CosmosDbExplorer\bin\Release\
path: src\CosmosDbExplorer\bin\Release\net6.0-windows

# - name: Setup NuGet
# uses: nuget/setup-nuget@v1
# with:
# nuget-version: '6.0.x'

# - name: Restore NuGet Packages
# run: nuget restore $env:Solution_Name

# - name: Build Application
# run: msbuild $env:Solution_Name /p:Configuration=Release

# - name: Upload build artifacts
# uses: actions/upload-artifact@v2
# with:
# name: CosmosDbExplorer
# path: src\CosmosDbExplorer\bin\Release\
29 changes: 15 additions & 14 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ jobs:
- name: Setup MSBuild.exe
uses: microsoft/[email protected]

- name: Setup NuGet
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.7.x'

- name: Restore NuGet Packages
run: nuget restore $env:Solution_Name
# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'

- name: Restore dependencies
run: dotnet restore $env:Solution_Name

- name: Build Application
run: msbuild $env:Solution_Name /p:Configuration=Release
run: dotnet build $env:Solution_Name --no-restore --configuration Release /p:Version=${{ steps.tag.outputs.version }}

- name: Zip Release folder
uses: papeloto/action-zip@v1
with:
files: src\CosmosDbExplorer\bin\Release\
files: src\CosmosDbExplorer\bin\Release\net6.0-windows
dest: CosmosDbExplorer.zip

- name: Automatic Release
Expand Down Expand Up @@ -81,29 +82,29 @@ jobs:
- name: 'Replace tokens Chocolatey files #1'
uses: datamonsters/replace-action@v2
with:
files: './src/CosmosDbExplorer/Chocolatey-Packages/cosmosdbexplorer/tools/chocolateyinstall.ps1'
files: './Chocolatey-Packages/cosmosdbexplorer/tools/chocolateyinstall.ps1'
replacements: '$version=${{ steps.tag.outputs.version }},$tag-name=$GIT_TAG_NAME'

- name: 'Replace tokens Chocolatey files #2'
uses: datamonsters/replace-action@v2
with:
files: './src/CosmosDbExplorer/Chocolatey-Packages/cosmosdbexplorer/cosmosdbexplorer.nuspec'
files: './Chocolatey-Packages/cosmosdbexplorer/cosmosdbexplorer.nuspec'
replacements: '$version=${{ steps.tag.outputs.version }},$tag-name=$GIT_TAG_NAME'

- name: Pack Chocolatey
uses: crazy-max/ghaction-chocolatey@v1
with:
args: pack ./src/CosmosDbExplorer/Chocolatey-Packages/cosmosdbexplorer/cosmosdbexplorer.nuspec
args: pack ./Chocolatey-Packages/cosmosdbexplorer/cosmosdbexplorer.nuspec

- name: Push Chocolatey
uses: crazy-max/ghaction-chocolatey@v1
with:
args: push ./src/CosmosDbExplorer/Chocolatey-Packages/cosmosdbexplorer/cosmosdbexplorer.${{ steps.tag.outputs.version }}.nupkg --source https://chocolatey.org/ --api-key=$CHOCOLATEY_API_KEY
args: push ./Chocolatey-Packages/cosmosdbexplorer/cosmosdbexplorer.${{ steps.tag.outputs.version }}.nupkg --source https://chocolatey.org/ --api-key=$CHOCOLATEY_API_KEY

- name: Upload chocolatey artifacts
uses: actions/upload-artifact@v2
with:
path: ./src/CosmosDbExplorer/Chocolatey-Packages/cosmosdbexplorer/cosmosdbexplorer.${{ steps.tag.outputs.version }}.nupkg
path: ./Chocolatey-Packages/cosmosdbexplorer/cosmosdbexplorer.${{ steps.tag.outputs.version }}.nupkg

# Autoupdater
autoupdater:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ $packageName = $env:ChocolateyPackageName
Install-ChocolateyZipPackage `
-PackageName $packageName `
-Url $url `
-UnzipLocation $toolsDir
-UnzipLocation $toolsDir `
-Checksum $checksum `
-ChecksumType 'sha256'

$softwareName = "CosmosDb Explorer"
$exePath = $toolsDir + "\cosmosdbexplorer.exe"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CosmosDbExplorer.Infrastructure
namespace CosmosDbExplorer.Core
{
public static class Constants
{
Expand Down
15 changes: 15 additions & 0 deletions src/CosmosDbExplorer.Core/Contracts/ICosmosDocument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Linq;

namespace CosmosDbExplorer.Core.Contracts
{
public interface ICosmosDocument : ICosmosResource, IEquatable<ICosmosDocument?>
{
string? Attachments { get; }
long TimeStamp { get; }
object? PartitionKey { get; }
bool HasPartitionKey { get; }
}
}
17 changes: 17 additions & 0 deletions src/CosmosDbExplorer.Core/Contracts/ICosmosQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using CosmosDbExplorer.Core.Models;

namespace CosmosDbExplorer.Core.Contracts
{
public interface ICosmosQuery
{
string QueryText { get; set; }
int MaxItemCount { get; set; }
string? ContinuationToken { get; set; }
bool EnableScanInQuery { get; set; }
bool EnableCrossPartitionQuery { get; set; }
int MaxDOP { get; set; }
int MaxBufferItem { get; set; }
Optional<object?> PartitionKeyValue { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/CosmosDbExplorer.Core/Contracts/ICosmosResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace CosmosDbExplorer.Core.Contracts
{
public interface ICosmosResource
{
string? Id { get; }
string? ETag { get; }
string? SelfLink { get; }
}
}
7 changes: 7 additions & 0 deletions src/CosmosDbExplorer.Core/Contracts/ICosmosScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace CosmosDbExplorer.Core.Contracts
{
public interface ICosmosScript : ICosmosResource
{
string Body { get; }
}
}
14 changes: 14 additions & 0 deletions src/CosmosDbExplorer.Core/Contracts/IDocumentRequestOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using CosmosDbExplorer.Core.Models;

namespace CosmosDbExplorer.Core.Contracts
{
public interface IDocumentRequestOptions
{
CosmosIndexingDirectives? IndexingDirective { get; set; }
CosmosConsistencyLevels? ConsistencyLevel { get; set; }
CosmosAccessConditionType AccessCondition { get; set; }
string? ETag { get; set; }
string[] PreTriggers { get; set; }
string[] PostTriggers { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CosmosDbExplorer.Core.Models;
using Microsoft.Azure.Cosmos;

namespace CosmosDbExplorer.Core.Contracts.Services
{
public interface ICosmosClientService
{
CosmosClient GetClient(CosmosConnection connection);

void DeleteClient(CosmosConnection connection);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CosmosDbExplorer.Core.Models;

namespace CosmosDbExplorer.Core.Contracts.Services
{
public interface ICosmosContainerService
{
Task<CosmosContainer> CreateContainerAsync(CosmosContainer container, int? throughput, bool? isAutoscale, CancellationToken cancellationToken);
Task DeleteContainserAsync(CosmosContainer container, CancellationToken cancellationToken);
Task<CosmosContainerMetric> GetContainerMetricsAsync(CosmosContainer container, CancellationToken cancellationToken);
Task<IList<CosmosContainer>> GetContainersAsync(CancellationToken cancellationToken);
Task<CosmosThroughput?> GetThroughputAsync(CosmosContainer container);
Task<CosmosContainer> UpdateContainerAsync(CosmosContainer container);
Task<CosmosThroughput> UpdateThroughputAsync(CosmosContainer container, int throughput, bool isAutoscale);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

using CosmosDbExplorer.Core.Models;

namespace CosmosDbExplorer.Core.Contracts.Services
{
public interface ICosmosDatabaseService
{
Task<CosmosDatabase> CreateDatabaseAsync(CosmosDatabase database, int? throughput, bool? isAutoscale, CancellationToken cancellationToken);
Task DeleteDatabaseAsync(CosmosDatabase database, CancellationToken cancellationToken);
Task<IList<CosmosDatabase>> GetDatabasesAsync(CancellationToken cancellationToken);
Task<CosmosThroughput?> GetThroughputAsync(CosmosDatabase database);
Task<CosmosThroughput> UpdateThroughputAsync(CosmosDatabase database, int throughput, bool isAutoscale);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CosmosDbExplorer.Core.Models;
using Newtonsoft.Json.Linq;

namespace CosmosDbExplorer.Core.Contracts.Services
{
public interface ICosmosDocumentService
{
Task<CosmosResult> DeleteDocumentsAsync(IEnumerable<ICosmosDocument> documents, CancellationToken cancellationToken);
Task<CosmosQueryResult<IReadOnlyCollection<JObject>>> ExecuteQueryAsync(ICosmosQuery query, CancellationToken cancellationToken);
Task<CosmosQueryResult<JObject>> GetDocumentAsync(ICosmosDocument document, IDocumentRequestOptions options, CancellationToken cancellation);
Task<CosmosQueryResult<IReadOnlyCollection<ICosmosDocument>>> GetDocumentsAsync(string? filter, int? maxItemsCount, string? continuationToken, CancellationToken cancellationToken);
Task<CosmosQueryResult<JObject>> SaveDocumentAsync(string content, IDocumentRequestOptions options, CancellationToken cancellation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using CosmosDbExplorer.Core.Models;

namespace CosmosDbExplorer.Core.Contracts.Services
{
public interface ICosmosScriptService
{
Task<CosmosResult> DeleteStoredProcedureAsync(CosmosStoredProcedure asset);
Task<CosmosResult> DeleteTriggerAsync(CosmosTrigger asset);
Task<CosmosResult> DeleteUserDefinedFunctionAsync(CosmosUserDefinedFunction asset);
Task<CosmosStoredProcedureResult> ExecuteStoredProcedureAsync(string storedProcedureId, string? partitionKey, dynamic[] parameters);
Task<IReadOnlyList<CosmosStoredProcedure>> GetStoredProceduresAsync(CancellationToken cancellationToken);
Task<IReadOnlyList<CosmosTrigger>> GetTriggersAsync(CancellationToken cancellationToken);
Task<IReadOnlyList<CosmosUserDefinedFunction>> GetUserDefinedFunctionsAsync(CancellationToken cancellationToken);
Task<CosmosStoredProcedure> SaveStoredProcedureAsync(CosmosStoredProcedure asset);
Task<CosmosTrigger> SaveTriggerAsync(CosmosTrigger asset);
Task<CosmosUserDefinedFunction> SaveUserDefinedFunctionAsync(CosmosUserDefinedFunction asset);
}
}
13 changes: 13 additions & 0 deletions src/CosmosDbExplorer.Core/Contracts/Services/ICosmosUserService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

using CosmosDbExplorer.Core.Models;

namespace CosmosDbExplorer.Core.Contracts.Services
{
public interface ICosmosUserService
{
Task<List<CosmosUser>> GetUsersAsync(CancellationToken cancellationToken);
}
}
11 changes: 11 additions & 0 deletions src/CosmosDbExplorer.Core/Contracts/Services/IFileService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace CosmosDbExplorer.Core.Contracts.Services
{
public interface IFileService
{
T Read<T>(string folderPath, string fileName);

void Save<T>(string folderPath, string fileName, T content);

void Delete(string folderPath, string fileName);
}
}
14 changes: 14 additions & 0 deletions src/CosmosDbExplorer.Core/CosmosDbExplorer.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>CosmosDbExplorer.Core</RootNamespace>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.26.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
33 changes: 33 additions & 0 deletions src/CosmosDbExplorer.Core/EnumDescriptionTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.ComponentModel;

namespace CosmosDbExplorer.Core
{
public class EnumDescriptionTypeConverter : EnumConverter
{
public EnumDescriptionTypeConverter(Type type)
: base(type)
{
}

public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
{
if (value != null)
{
var fi = value.GetType().GetField(value.ToString());
if (fi != null)
{
var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
return ((attributes.Length > 0) && (!string.IsNullOrEmpty(attributes[0].Description))) ? attributes[0].Description : value.ToString();
}
}

return string.Empty;
}

return base.ConvertTo(context, culture, value, destinationType);
}
}
}
Loading

0 comments on commit e0e333d

Please sign in to comment.