Skip to content

Commit

Permalink
many format fix with dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Feb 7, 2023
1 parent dd0eb98 commit f7a3898
Show file tree
Hide file tree
Showing 121 changed files with 1,015 additions and 423 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

<h3 align="center">

![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=develop)
![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=feature/format-improvements)
[![NuGet](https://img.shields.io/nuget/vpre/DotNetStac)](https://www.nuget.org/packages/DotNetStac/)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/develop/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/feature/format-improvements/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![Gitter](https://img.shields.io/gitter/room/SpatioTemporal-Asset-Catalog/Lobby?color=yellow)](https://gitter.im/SpatioTemporal-Asset-Catalog/Lobby)
[![License](https://img.shields.io/badge/license-AGPL3-blue.svg)](LICENSE)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Terradue/DotNetStac/master?filepath=example.ipynb)
Expand Down
10 changes: 8 additions & 2 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ dotnet_diagnostic.RS0018.severity = warning
dotnet_diagnostic.RS0010.severity = warning

# Microsoft.CodeAnalysis.CSharp.Features
# Prefix local calls with this
# Name: Before: After:
dotnet_diagnostic.IDE0001.severity = warning # Simplify names System.Version version; Version version;
dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) System.Version.Equals("1", "2"); Version.Equals("1", "2");
Expand All @@ -396,6 +397,11 @@ dotnet_diagnostic.VSTHRD111.severity = none # Use ConfigureAwait(true).
dotnet_diagnostic.VSSDK006.severity = none # Check whether the result of GetService calls is null

# Microsoft.CodeAnalysis.VisualBasic.CodeStyle/Microsoft.CodeAnalysis.CSharp.CodeStyle
dotnet_diagnostic.IDE0073.severity = warning # Enforce file header
file_header_template = Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.
dotnet_diagnostic.IDE0073.severity = warning # Enforce file header

file_header_template = Copyright (c) by Terradue Srl. All Rights Reserved.\nLicense under the AGPL, Version 3.0.\nFile Name: {fileName}

dotnet_diagnostic.SA1636.severity = none # Disable file header matching
dotnet_diagnostic.SA1501.severity = error # Braces must not be omitted
dotnet_diagnostic.SA1101.severity = warning # Prefix local calls with this
dotnet_diagnostic.SA1507.severity = warning # Code should not contain multiple blank lines in a row
6 changes: 5 additions & 1 deletion src/DotNetStac.Test/Catalog/CatalogTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: CatalogTests.cs

using System;
using Newtonsoft.Json;
using Xunit;

Expand Down
7 changes: 4 additions & 3 deletions src/DotNetStac.Test/Catalog/StacRepositoryCatalogTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: StacRepositoryCatalogTests.cs

using Xunit;

namespace Stac.Test.Catalog
Expand Down
15 changes: 8 additions & 7 deletions src/DotNetStac.Test/Collection/CollectionTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: CollectionTests.cs

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using GeoJSON.Net;
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stac.Collection;
Expand Down Expand Up @@ -45,10 +46,10 @@ public void CanDeserializeSentinel2Sample()

Assert.IsType<StacSummaryRangeObject<DateTime>>(item.Summaries["datetime"]);

Assert.Equal<DateTime>(DateTime.Parse("2015-06-23T00:00:00Z").ToUniversalTime(), (item.Summaries["datetime"] as StacSummaryRangeObject<DateTime>).Min);
Assert.Equal(DateTime.Parse("2015-06-23T00:00:00Z").ToUniversalTime(), (item.Summaries["datetime"] as StacSummaryRangeObject<DateTime>).Min);

Assert.Equal<long>(32601, (item.Summaries["proj:epsg"] as StacSummaryValueSet<long>).Min());
Assert.Equal<long>(32660, (item.Summaries["proj:epsg"] as StacSummaryValueSet<long>).Max());
Assert.Equal(32601, (item.Summaries["proj:epsg"] as StacSummaryValueSet<long>).Min());
Assert.Equal(32660, (item.Summaries["proj:epsg"] as StacSummaryValueSet<long>).Max());
Assert.Equal<long>(60, (item.Summaries["proj:epsg"] as StacSummaryValueSet<long>).Count);

Assert.Equal(13, item.Summaries["eo:bands"].LongCount());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: StacRepositoryCollectionTests.cs

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;

namespace Stac.Test.Catalog
Expand Down
11 changes: 6 additions & 5 deletions src/DotNetStac.Test/Common/PatchHelpersTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using GeoJSON.Net.Geometry;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: PatchHelpersTests.cs

using Newtonsoft.Json;
using Stac.Collection;
using Stac.Common;
using Xunit;

Expand All @@ -16,7 +17,7 @@ public void PatchStacItemTest()

StacItem patchItem = StacConvert.Deserialize<StacItem>(GetJson("Common", "Patch"));

StacItem patchedItem = baseItem.Patch<StacItem>(patchItem);
StacItem patchedItem = baseItem.Patch(patchItem);

JsonAssert.AreEqual(GetJson("Common", "PatchedItem"), StacConvert.Serialize(patchedItem));
}
Expand All @@ -28,7 +29,7 @@ public void PatchStacItemTest2()

Patch patchItem = JsonConvert.DeserializeObject<Patch>(GetJson("Common", "Patch2"));

StacItem patchedItem = baseItem.Patch<StacItem>(patchItem);
StacItem patchedItem = baseItem.Patch(patchItem);

JsonAssert.AreEqual(GetJson("Common", "PatchedItem2"), StacConvert.Serialize(patchedItem));
}
Expand Down
8 changes: 6 additions & 2 deletions src/DotNetStac.Test/Common/StacAccessorsHelpersTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System.Collections.Generic;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: StacAccessorsHelpersTests.cs

using System.Collections.Generic;
using GeoJSON.Net.Geometry;
using Stac.Collection;
using Stac.Common;
Expand Down Expand Up @@ -54,7 +58,7 @@ public void GetPropertyTest()

item.SetProperty("summary", summaryItemType);

Assert.NotNull(item.GetProperty<SummaryItemType>("summary"));
Assert.NotNull(item.GetProperty<SummaryItemType?>("summary"));

summaryItemType = SummaryItemType.RangeObject;

Expand Down
25 changes: 14 additions & 11 deletions src/DotNetStac.Test/Examples/Example1Test.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: Example1Test.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stac.Collection;
Expand All @@ -12,19 +15,19 @@ namespace Stac.Test.Example
public class Example1Test : TestBase
{
//[Fact]
public void Deserialize()
{
Uri catalogUri = new Uri("https://landsat-stac.s3.amazonaws.com/catalog.json");
StacCatalog catalog = StacConvert.Deserialize<StacCatalog>(httpClient.GetStringAsync(catalogUri).GetAwaiter().GetResult());
// public void Deserialize()
// {
// Uri catalogUri = new Uri("https://landsat-stac.s3.amazonaws.com/catalog.json");
// StacCatalog catalog = StacConvert.Deserialize<StacCatalog>(httpClient.GetStringAsync(catalogUri).GetAwaiter().GetResult());

Console.Out.WriteLine(catalog.Id);
Console.Out.WriteLine(catalog.StacVersion);
// Console.Out.WriteLine(catalog.Id);
// Console.Out.WriteLine(catalog.StacVersion);

ListChildrensItemsAndAssets(catalog, catalogUri);
// ListChildrensItemsAndAssets(catalog, catalogUri);

}
// }

void ListChildrensItemsAndAssets(IStacParent catalog, Uri baseUri, string prefix = "", int limit = 2)
private void ListChildrensItemsAndAssets(IStacParent catalog, Uri baseUri, string prefix = "", int limit = 2)
{
// Get children first (sub catalogs and collections)
foreach (var childLink in catalog.GetChildrenLinks().Concat(catalog.GetItemLinks()))
Expand Down
6 changes: 5 additions & 1 deletion src/DotNetStac.Test/Exceptions/ExceptionsTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: ExceptionsTests.cs

using System;
using Stac.Exceptions;
using Xunit;

Expand Down
14 changes: 9 additions & 5 deletions src/DotNetStac.Test/Extensions/AlternateExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.IO;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: AlternateExtensionTests.cs

using System;
using Newtonsoft.Json;
using Stac.Extensions.Alternate;
using Xunit;
Expand All @@ -9,7 +12,7 @@ namespace Stac.Test.Extensions
public class AlternateExtensionTests : TestBase
{
[Fact]
public async System.Threading.Tasks.Task SetAlternateAsset()
public System.Threading.Tasks.Task SetAlternateAsset()
{
var simpleJson = GetJson("Extensions", "MinimalSample");
ValidateJson(simpleJson);
Expand All @@ -32,18 +35,19 @@ public async System.Threading.Tasks.Task SetAlternateAsset()
JsonAssert.AreEqual(expectedJson, actualJson);

Assert.Equal("s3://bucket/key/srid.csv", simpleitem.Assets["srid"].AlternateExtension().AlternateAssets["s3"].Uri.ToString());
return System.Threading.Tasks.Task.CompletedTask;
}

[Fact]
public async System.Threading.Tasks.Task LS9Alternates()
public System.Threading.Tasks.Task LS9Alternates()
{
var simpleJson = GetJson("Extensions", "LS9Sample");
ValidateJson(simpleJson);

StacItem ls9item = StacConvert.Deserialize<StacItem>(simpleJson);

Assert.Equal("s3://usgs-landsat/collection02/level-2/standard/oli-tirs/2022/088/084/LC09_L2SP_088084_20220405_20220407_02_T2/LC09_L2SP_088084_20220405_20220407_02_T2_thumb_small.jpeg", ls9item.Assets["thumbnail"].AlternateExtension().AlternateAssets["s3"].Uri.ToString());
return System.Threading.Tasks.Task.CompletedTask;
}

}
}
12 changes: 6 additions & 6 deletions src/DotNetStac.Test/Extensions/DatacubeExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: DatacubeExtensionTests.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stac.Extensions.Datacube;
using Stac.Extensions.Eo;
using Xunit;

namespace Stac.Test.Extensions
Expand Down Expand Up @@ -106,7 +106,7 @@ public void CanSerializeDatacube123()
item.DatacubeStacExtension().Variables.Add("temp", tempVar);

var colorVar = new DatacubeVariable();
colorVar.Dimensions = new string[] { };
colorVar.Dimensions = Array.Empty<string>();
colorVar.Type = DatacubeVariableType.auxiliary;
colorVar.Values = new string[] { "red", "green", "blue" };
item.DatacubeStacExtension().Variables.Add("color", colorVar);
Expand Down
11 changes: 7 additions & 4 deletions src/DotNetStac.Test/Extensions/EoExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: EoExtensionTests.cs

using System;
using System.Collections.Generic;
using System.Linq;
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stac.Extensions.Eo;
using Xunit;

Expand Down Expand Up @@ -109,8 +112,8 @@ public void CreateEoExtension()
EoStacExtension eo = item.EoExtension();
eo.CloudCover = 0;

Assert.Equal<double>(0.0, eo.CloudCover.Value);
Assert.Equal<double>(0.0, double.Parse(asset.Properties["eo:cloud_cover"].ToString()));
Assert.Equal(0.0, eo.CloudCover.Value);
Assert.Equal(0.0, double.Parse(asset.Properties["eo:cloud_cover"].ToString()));

var actualJson = StacConvert.Serialize(item);

Expand Down
12 changes: 6 additions & 6 deletions src/DotNetStac.Test/Extensions/FileExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: FileExtensionTests.cs

using System;
using System.IO;
using System.Linq;
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stac.Extensions.File;
using Xunit;

Expand All @@ -24,7 +24,7 @@ public async System.Threading.Tasks.Task SetPropertiesFromFileInfo()
new Uri("file:///srid.csv"),
new System.Net.Mime.ContentType("text/csv"),
"System reference Ids");
await stacAsset.FileExtension().SetFileExtensionProperties(new System.IO.FileInfo("SRID.csv"));
await stacAsset.FileExtension().SetFileExtensionProperties(new FileInfo("SRID.csv"));
simpleitem.Assets.Add("srid", stacAsset);

Assert.Equal<ulong>(1536937, stacAsset.FileExtension().Size.Value);
Expand Down
5 changes: 4 additions & 1 deletion src/DotNetStac.Test/Extensions/ItemCollectionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Newtonsoft.Json;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: ItemCollectionTests.cs

using Stac.Extensions.ItemCollections;
using Xunit;

Expand Down
11 changes: 4 additions & 7 deletions src/DotNetStac.Test/Extensions/RasterExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Stac.Extensions.Eo;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: RasterExtensionTests.cs

using Xunit;

namespace Stac.Test.Extensions
Expand Down
11 changes: 7 additions & 4 deletions src/DotNetStac.Test/Extensions/StorageExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.IO;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: StorageExtensionTests.cs

using System;
using Newtonsoft.Json;
using Stac.Extensions.Alternate;
using Xunit;
Expand All @@ -9,7 +12,7 @@ namespace Stac.Test.Extensions
public class StorageExtensionTests : TestBase
{
[Fact]
public async System.Threading.Tasks.Task SetAlternateStorageAsset()
public System.Threading.Tasks.Task SetAlternateStorageAsset()
{
var simpleJson = GetJson("Extensions", "MinimalSample");
ValidateJson(simpleJson);
Expand Down Expand Up @@ -37,7 +40,7 @@ public async System.Threading.Tasks.Task SetAlternateStorageAsset()

Assert.Equal("s3://bucket/key/srid.csv", simpleitem.Assets["srid"].AlternateExtension().AlternateAssets["s3"].Uri.ToString());
Assert.Equal("fr-par", simpleitem.Assets["srid"].AlternateExtension().AlternateAssets["s3"].StorageExtension().Region);
return System.Threading.Tasks.Task.CompletedTask;
}

}
}
6 changes: 5 additions & 1 deletion src/DotNetStac.Test/Extensions/VersionExtensionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Newtonsoft.Json;
// Copyright (c) by Terradue Srl. All Rights Reserved.
// License under the AGPL, Version 3.0.
// File Name: VersionExtensionTests.cs

using Newtonsoft.Json;
using Stac.Extensions.Version;
using Xunit;

Expand Down
Loading

0 comments on commit f7a3898

Please sign in to comment.