Skip to content

Commit

Permalink
Elements must appear in the correct order
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Feb 7, 2023
1 parent 87c4fb6 commit 6505476
Show file tree
Hide file tree
Showing 40 changed files with 328 additions and 271 deletions.
4 changes: 4 additions & 0 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,16 @@ dotnet_diagnostic.SA1101.severity = warning # Prefix local calls with this
dotnet_diagnostic.SA1119.severity = warning # Statement must not use unnecessary parenthesis
dotnet_diagnostic.SA1124.severity = warning # Do not use regions
dotnet_diagnostic.SA1127.severity = warning # Generic type constraints must be on their own line or share line with previous
dotnet_diagnostic.SA1128.severity = warning # Put constructor initializers on their own line
dotnet_diagnostic.SA1201.severity = warning # Elements must appear in the correct order
dotnet_diagnostic.SA1501.severity = warning # Braces must not be omitted
dotnet_diagnostic.SA1503.severity = warning # Braces must not be omitted
dotnet_diagnostic.SA1506.severity = warning # Element documentation header must not be preceded by blank line
dotnet_diagnostic.SA1507.severity = warning # Code should not contain multiple blank lines in a row
dotnet_diagnostic.SA1513.severity = warning # Closing brace must be followed by blank line
dotnet_diagnostic.SA1514.severity = warning # Element documentation header must be preceded by blank line
dotnet_diagnostic.SA1515.severity = warning # Single-line comment must be preceded by blank line
dotnet_diagnostic.SA1516.severity = warning # Elements must be separated by blank line
dotnet_diagnostic.SA1623.severity = warning # Property summary documentation must match accessors
dotnet_diagnostic.SA1626.severity = warning # Single-line comments must not use documentation style slashes
dotnet_diagnostic.SA1636.severity = none # Disable file header matching
Expand Down
10 changes: 5 additions & 5 deletions src/DotNetStac/Collection/IStacSummaryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ namespace Stac.Collection
/// </summary>
public interface IStacSummaryItem : IEnumerable<JToken>
{
/// <summary>
/// Gets or sets the summary value with the specified fields (for objects only)
/// </summary>
JToken this[object key] { get; }

/// <summary>
/// Gets the summary item as a JToken
/// </summary>
/// <value>
/// The summary item as a JToken
/// </value>
JToken AsJToken { get; }

/// <summary>
/// Gets or sets the summary value with the specified fields (for objects only)
/// </summary>
JToken this[object key] { get; }

IEnumerable<object> Enumerate();

Expand Down
16 changes: 8 additions & 8 deletions src/DotNetStac/Collection/StacSummaryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ protected StacSummaryItem(JToken summary)
this.summary = summary;
}

/// <summary>
/// Gets jToken transformer
/// </summary>
/// <value>
/// JToken transformer
/// </value>
public JToken AsJToken => this.summary;

/// <summary>
/// accessor of fields in the object
/// </summary>
Expand All @@ -38,14 +46,6 @@ public JToken this[object key]
}
}

/// <summary>
/// Gets jToken transformer
/// </summary>
/// <value>
/// JToken transformer
/// </value>
public JToken AsJToken => this.summary;

/// <inheritdoc/>
public abstract IEnumerable<object> Enumerate();

Expand Down
6 changes: 4 additions & 2 deletions src/DotNetStac/Collection/StacSummaryRangeObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class StacSummaryRangeObject<T> : StacSummaryItem
/// </summary>
/// <param name="summary">JSON Range object</param>
/// <exception cref="ArgumentException">Thrown when neither "minimum" nor "maximum" fields are present in the range object.</exception>
public StacSummaryRangeObject(JObject summary) : base(summary)
public StacSummaryRangeObject(JObject summary)
: base(summary)
{
if (!summary.ContainsKey("minimum") || !summary.ContainsKey("maximum"))
{
Expand All @@ -32,7 +33,8 @@ public StacSummaryRangeObject(JObject summary) : base(summary)
/// </summary>
/// <param name="min"></param>
/// <param name="max"></param>
public StacSummaryRangeObject(T min, T max) : base(new JObject())
public StacSummaryRangeObject(T min, T max)
: base(new JObject())
{
this.Min = min;
this.Max = max;
Expand Down
27 changes: 15 additions & 12 deletions src/DotNetStac/Collection/StacSummaryValueSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,29 @@ public class StacSummaryValueSet<T> : StacSummaryItem, IEnumerable<T>
/// <summary>
/// Initialize an empty Summary Value Set
/// </summary>
public StacSummaryValueSet() : base(new JArray())
public StacSummaryValueSet()
: base(new JArray())
{
}

/// <summary>
/// Initialize a Summary Value Set with a JSON array
/// </summary>
/// <param name="summarySet">JSON Array</param>
public StacSummaryValueSet(JArray summarySet) : base(summarySet)
public StacSummaryValueSet(JArray summarySet)
: base(summarySet)
{
}

/// <summary>
/// Initialize a Summary Value Set with a set of values
/// </summary>
/// <param name="summarySet">set of values</param>
public StacSummaryValueSet(IEnumerable<T> summarySet) : base(new JArray(summarySet))
public StacSummaryValueSet(IEnumerable<T> summarySet)
: base(new JArray(summarySet))
{
}

/// <summary>
/// Add a value item in the Summary Value Set
/// </summary>
/// <param name="item">value item</param>
public void Add(T item)
{
((JArray)this.summary).Add(item);
}

/// <summary>
/// Gets summary Value Set total of items
/// </summary>
Expand All @@ -66,6 +60,15 @@ public void Add(T item)
/// </value>
public IEnumerable<T> SummarySet { get => this.summary.ToObject<List<T>>(); }

/// <summary>
/// Add a value item in the Summary Value Set
/// </summary>
/// <param name="item">value item</param>
public void Add(T item)
{
((JArray)this.summary).Add(item);
}

IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return this.SummarySet.GetEnumerator();
Expand Down
3 changes: 2 additions & 1 deletion src/DotNetStac/Common/PropertyObservableCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class PropertyObservableCollection<T> : ObservableCollection<T>
/// </summary>
/// <param name="propertiesContainer">The properties container.</param>
/// <param name="key">The property key.</param>
public PropertyObservableCollection(IStacPropertiesContainer propertiesContainer, string key) : base()
public PropertyObservableCollection(IStacPropertiesContainer propertiesContainer, string key)
: base()
{
this.PropertiesContainer = propertiesContainer;
this.Key = key;
Expand Down
12 changes: 6 additions & 6 deletions src/DotNetStac/Converters/CollectionConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ namespace Stac.Converters
{
public class CollectionConverter<T> : JsonConverter
{
/// <inheritdoc/>
public override bool CanRead => true;

/// <inheritdoc/>
public override bool CanWrite => true;

/// <inheritdoc/>
public override bool CanConvert(Type objectType)
{
Expand All @@ -30,12 +36,6 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
return new Collection<T>();
}

/// <inheritdoc/>
public override bool CanRead => true;

/// <inheritdoc/>
public override bool CanWrite => true;

/// <inheritdoc/>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
Expand Down
9 changes: 6 additions & 3 deletions src/DotNetStac/Exceptions/InvalidStacDataException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ public InvalidStacDataException()
{
}

public InvalidStacDataException(string message) : base(message)
public InvalidStacDataException(string message)
: base(message)
{
}

public InvalidStacDataException(string message, Exception innerException) : base(message, innerException)
public InvalidStacDataException(string message, Exception innerException)
: base(message, innerException)
{
}

protected InvalidStacDataException(SerializationInfo info, StreamingContext context) : base(info, context)
protected InvalidStacDataException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/DotNetStac/Exceptions/InvalidStacSchemaException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ public InvalidStacSchemaException()
{
}

public InvalidStacSchemaException(string message) : base(message)
public InvalidStacSchemaException(string message)
: base(message)
{
}

public InvalidStacSchemaException(string message, Exception innerException) : base(message, innerException)
public InvalidStacSchemaException(string message, Exception innerException)
: base(message, innerException)
{
}

protected InvalidStacSchemaException(SerializationInfo info, StreamingContext context) : base(info, context)
protected InvalidStacSchemaException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class AlternateStacExtension : StacPropertiesContainerExtension, IStacAss

private static IDictionary<string, Type> assetFields;

internal AlternateStacExtension(StacAsset stacAsset) : base(JsonSchemaUrl, stacAsset)
internal AlternateStacExtension(StacAsset stacAsset)
: base(JsonSchemaUrl, stacAsset)
{
assetFields = new Dictionary<string, Type>();
assetFields.Add(AlternateField, typeof(AlternateAssetObject[]));
Expand All @@ -36,6 +37,7 @@ internal AlternateStacExtension(StacAsset stacAsset) : base(JsonSchemaUrl, stacA
public IDictionary<string, AlternateAssetObject> AlternateAssets
{
get { return this.StacPropertiesContainer.GetProperty<Dictionary<string, AlternateAssetObject>>(AlternateField); }

set
{
if (value == null || value.Count() == 0)
Expand Down
47 changes: 26 additions & 21 deletions src/DotNetStac/Extensions/Datacube/DatacubeDimensionObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class DatacubeDimension : IStacPropertiesContainer
protected object values;
protected double? step;

public DatacubeDimension()
{
this.properties = new Dictionary<string, object>();
}

/// <summary>
/// Gets or sets type of the dimension.
/// </summary>
Expand Down Expand Up @@ -78,18 +83,18 @@ public class DatacubeDimension : IStacPropertiesContainer
/// <inheritdoc/>
[JsonIgnore]
public IStacObject StacObjectContainer => null;

public DatacubeDimension()
{
this.properties = new Dictionary<string, object>();
}
}

public class DatacubeDimensionSpatial : DatacubeDimension
{
protected DatacubeAxis? axis;
protected object reference_system;

public DatacubeDimensionSpatial()
: base()
{
}

/// <summary>
/// Gets or sets axis of the spatial dimension.
/// </summary>
Expand All @@ -107,15 +112,12 @@ public class DatacubeDimensionSpatial : DatacubeDimension
/// </value>
[JsonProperty("reference_system")]
public object ReferenceSystem { get => this.reference_system; set => this.reference_system = value; }

public DatacubeDimensionSpatial() : base()
{
}
}

public class DatacubeDimensionSpatialHorizontal : DatacubeDimensionSpatial
{
public DatacubeDimensionSpatialHorizontal() : base()
public DatacubeDimensionSpatialHorizontal()
: base()
{
this.axis = DatacubeAxis.x;
}
Expand All @@ -125,6 +127,12 @@ public class DatacubeDimensionSpatialVertical : DatacubeDimensionSpatial
{
private string unit;

public DatacubeDimensionSpatialVertical()
: base()
{
this.axis = DatacubeAxis.z;
}

/// <summary>
/// Gets or sets the unit of measurement for the data, preferably compliant to <seealso href="https://ncics.org/portfolio/other-resources/udunits2">UDUNITS-2</seealso> units (singular).
/// </summary>
Expand All @@ -133,17 +141,13 @@ public class DatacubeDimensionSpatialVertical : DatacubeDimensionSpatial
/// </value>
[JsonProperty("unit")]
public string Unit { get => this.unit; set => this.unit = value; }

public DatacubeDimensionSpatialVertical() : base()
{
this.axis = DatacubeAxis.z;
}
}

public class DatacubeDimensionTemporal : DatacubeDimension
{

public DatacubeDimensionTemporal() : base()
public DatacubeDimensionTemporal()
: base()
{

}
Expand All @@ -155,6 +159,12 @@ public class DatacubeDimensionAdditional : DatacubeDimension
private string unit;
protected object reference_system;

public DatacubeDimensionAdditional()
: base()
{

}

/// <summary>
/// Gets or sets the unit of measurement for the data, preferably compliant to <seealso href="https://ncics.org/portfolio/other-resources/udunits2">UDUNITS-2</seealso> units (singular).
/// </summary>
Expand All @@ -172,10 +182,5 @@ public class DatacubeDimensionAdditional : DatacubeDimension
/// </value>
[JsonProperty("reference_system")]
public object ReferenceSystem { get => this.reference_system; set => this.reference_system = value; }

public DatacubeDimensionAdditional() : base()
{

}
}
}
Loading

0 comments on commit 6505476

Please sign in to comment.