Skip to content

Commit

Permalink
Remove all newtonsoft references and transform into system.text.json (e…
Browse files Browse the repository at this point in the history
…clipse-aaspe#305)

* update newtonsoft to system.text.json

* add more verifications

* add transformer and tests

* remove unused using

* fix smaller issues with AdminShellConverters and apply necessary nullable for AssetAdministrationShell parameter assetInformation

* remove unused parameters

* Transform usings to System.Text.Json

* Fix  system.text.json usage

* remove not references AdminShellCollections.cs

* fix test setup in AdminShellCollectionTests.cs

* add tests

* Add tests

* Fix method modifiers

* Add Tests for AdaptiveFilterContractResolver

* remove newtonsoft references in favor to System.Text.Json

* update newtonsoft to system.text.json

* Transform to System.Text.Json in Startup.cs

* Transform to System.Text.Json in ServerConfiguration.cs

* Transform to System.Text.Json

* Transform AasxPluginOptionSerialization.cs to System.Text.Json

* Transform AasxRestClient.cs to System.Text.Json and Delete EnergyModel_SourceSystem_Azure.cs

* transform first chunk of Program.cs to System.Text.Json

WARNING: Work in progress

* Transform Program.cs to use System.Text.Json

* Transform SecurityClient.cs to System.Text.Json

* transform TimeSeries.cs to System.Text.Json

* Transform TimeSeriesPlotting.cs to use System.Text.Json

* Transform to System.text.Json

* Transform ToJson Method to System.Text.Json

* Transfrom simple values to System.Text.Json

* update formatter to system.text.json in Startup.cs

* Transform Registry Lib to System.Text.Json

* fix spelling issue 'retrived' to 'retrieved'

* Remove remaining newtonsoft references

* Remove Newtonsoft references

* update CHANGELOG.md

* Revert

* fix modifiers

* revert nullable

* fix merge issues

* update remarks

* fix merge issues

* Fix swagger initialisation

* fix MessageType serialization and remove hungarian notation

* fix hungarian notation

* re-add missing nullchecks

* fix missing null check

* fix nullable errors in AASXFileServerAPIApi.cs

* fix nulltype errors in AssetAdministrationShellRepositoryAPIApi.cs

* fix null types

* update null fixes in SerializationAPIApi.cs

* fix nullables

* fix nullables and error handling in SubmodelRepositoryAPIApi.cs

* reformat AssetAdministrationShellRegistryAPIApi.cs

* Fix API nullables and error handling

* refactor ServiceDescription.cs and Description.cs

* Make ServiceDescription.cs testable and create tests

* add tests DescriptionAPIApiControllerTests.cs

* apply resharper suggestions

* add tests for GenerateSerializationService.cs

* update documentation for Logging interfaces and classes

* Fix MessageTypeEnum not displayed as text in HTTP result

* Fix DateTime handling in ExceptionMiddleware.cs

* fix nullability issue

* refactor namings in RegistryInitializerService.cs

* Refactor RegistryInitializerService.cs and fix nullable bugs

* fix merging issues

* fix merging issues
  • Loading branch information
Freezor authored Jul 4, 2024
1 parent 51cdedb commit 6daf0f7
Show file tree
Hide file tree
Showing 140 changed files with 9,098 additions and 6,543 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed

- I40Languages.cs and I40Messages.cs removed (@Freezor)
- References and usings of Newtonsoft in favor of a complete usage of System.Text.Json in the whole project. (@Freezor)

### Updated

Expand Down
1 change: 0 additions & 1 deletion src/AasCore.Aas3_0/AasCore.Aas3_0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
252 changes: 126 additions & 126 deletions src/AasCore.Aas3_0/jsonization.cs

Large diffs are not rendered by default.

71 changes: 36 additions & 35 deletions src/AasCore.Aas3_0/types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Do NOT edit or append.
*/

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq; // can't alias
Expand All @@ -12,6 +11,8 @@

namespace AasCore.Aas3_0
{
using System.Text.Json.Serialization;

/// <summary>
/// Represent a general class of an AAS model.
/// </summary>
Expand Down Expand Up @@ -1233,7 +1234,7 @@ public interface IAssetAdministrationShell :
/// <summary>
/// Meta-information about the asset the AAS is representing.
/// </summary>
public IAssetInformation AssetInformation { get; set; }
public IAssetInformation? AssetInformation { get; set; }

/// <summary>
/// References to submodels of the AAS.
Expand Down Expand Up @@ -1345,7 +1346,7 @@ public class AssetAdministrationShell : IAssetAdministrationShell
/// <summary>
/// Meta-information about the asset the AAS is representing.
/// </summary>
public IAssetInformation AssetInformation { get; set; }
public IAssetInformation? AssetInformation { get; set; }

/// <summary>
/// References to submodels of the AAS.
Expand Down Expand Up @@ -1629,7 +1630,7 @@ public T Transform<TContext, T>(

public AssetAdministrationShell(
string? id,
IAssetInformation assetInformation,
IAssetInformation? assetInformation,
List<IExtension>? extensions = null,
string? category = null,
string? idShort = null,
Expand Down Expand Up @@ -2893,12 +2894,12 @@ public interface IRelationshipElement : ISubmodelElement
/// <summary>
/// Reference to the first element in the relationship taking the role of the subject.
/// </summary>
public IReference First { get; set; }
public IReference? First { get; set; }

/// <summary>
/// Reference to the second element in the relationship taking the role of the object.
/// </summary>
public IReference Second { get; set; }
public IReference? Second { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -3006,12 +3007,12 @@ public class RelationshipElement : IRelationshipElement
/// <summary>
/// Reference to the first element in the relationship taking the role of the subject.
/// </summary>
public IReference First { get; set; }
public IReference? First { get; set; }

/// <summary>
/// Reference to the second element in the relationship taking the role of the object.
/// </summary>
public IReference Second { get; set; }
public IReference? Second { get; set; }

#region Parent

Expand Down Expand Up @@ -3303,8 +3304,8 @@ public T Transform<TContext, T>(
}

public RelationshipElement(
IReference first,
IReference second,
IReference? first,
IReference? second,
List<IExtension>? extensions = null,
string? category = null,
string? idShort = null,
Expand Down Expand Up @@ -7499,12 +7500,12 @@ public class AnnotatedRelationshipElement : IAnnotatedRelationshipElement
/// <summary>
/// Reference to the first element in the relationship taking the role of the subject.
/// </summary>
public IReference First { get; set; }
public IReference? First { get; set; }

/// <summary>
/// Reference to the second element in the relationship taking the role of the object.
/// </summary>
public IReference Second { get; set; }
public IReference? Second { get; set; }

/// <summary>
/// A data element that represents an annotation that holds for the relationship
Expand Down Expand Up @@ -7833,8 +7834,8 @@ public T Transform<TContext, T>(
}

public AnnotatedRelationshipElement(
IReference first,
IReference second,
IReference? first,
IReference? second,
List<IExtension>? extensions = null,
string? category = null,
string? idShort = null,
Expand Down Expand Up @@ -8494,7 +8495,7 @@ public interface IEventPayload : IClass
/// <see cref="Aas.AssetAdministrationShell" />, <see cref="Aas.Submodel" />,
/// <see cref="Aas.ISubmodelElement" />'s.
/// </summary>
public IReference Source { get; set; }
public IReference? Source { get; set; }

/// <summary>
/// <see cref="Aas.IHasSemantics.SemanticId" /> of the source event element, if available
Expand All @@ -8511,7 +8512,7 @@ public interface IEventPayload : IClass
/// Can be <see cref="Aas.AssetAdministrationShell" />, <see cref="Aas.Submodel" /> or
/// <see cref="Aas.ISubmodelElement" />.
/// </remarks>
public IReference ObservableReference { get; set; }
public IReference? ObservableReference { get; set; }

/// <summary>
/// <see cref="Aas.IHasSemantics.SemanticId" /> of the referable which defines the scope of
Expand Down Expand Up @@ -8561,7 +8562,7 @@ public class EventPayload : IEventPayload
/// <see cref="Aas.AssetAdministrationShell" />, <see cref="Aas.Submodel" />,
/// <see cref="Aas.ISubmodelElement" />'s.
/// </summary>
public IReference Source { get; set; }
public IReference? Source { get; set; }

/// <summary>
/// <see cref="Aas.IHasSemantics.SemanticId" /> of the source event element, if available
Expand All @@ -8578,7 +8579,7 @@ public class EventPayload : IEventPayload
/// Can be <see cref="Aas.AssetAdministrationShell" />, <see cref="Aas.Submodel" /> or
/// <see cref="Aas.ISubmodelElement" />.
/// </remarks>
public IReference ObservableReference { get; set; }
public IReference? ObservableReference { get; set; }

/// <summary>
/// <see cref="Aas.IHasSemantics.SemanticId" /> of the referable which defines the scope of
Expand Down Expand Up @@ -8735,8 +8736,8 @@ public T Transform<TContext, T>(
}

public EventPayload(
IReference source,
IReference observableReference,
IReference? source,
IReference? observableReference,
string? timeStamp,
IReference? sourceSemanticId = null,
IReference? observableSemanticId = null,
Expand Down Expand Up @@ -8785,7 +8786,7 @@ public interface IBasicEventElement : IEventElement
/// Reference to a referable, e.g., a data element or
/// a submodel, that is being observed.
/// </remarks>
public IReference Observed { get; set; }
public IReference? Observed { get; set; }

/// <summary>
/// Direction of event.
Expand Down Expand Up @@ -8973,7 +8974,7 @@ public class BasicEventElement : IBasicEventElement
/// Reference to a referable, e.g., a data element or
/// a submodel, that is being observed.
/// </remarks>
public IReference Observed { get; set; }
public IReference? Observed { get; set; }

/// <summary>
/// Direction of event.
Expand Down Expand Up @@ -9342,7 +9343,7 @@ public T Transform<TContext, T>(
}

public BasicEventElement(
IReference observed,
IReference? observed,
Direction direction,
StateOfEvent state,
List<IExtension>? extensions = null,
Expand Down Expand Up @@ -9960,7 +9961,7 @@ public interface IOperationVariable : IClass
/// <summary>
/// Describes an argument or result of an operation via a submodel element
/// </summary>
public ISubmodelElement Value { get; set; }
public ISubmodelElement? Value { get; set; }
}

/// <summary>
Expand All @@ -9972,7 +9973,7 @@ public class OperationVariable : IOperationVariable
/// <summary>
/// Describes an argument or result of an operation via a submodel element
/// </summary>
public ISubmodelElement Value { get; set; }
public ISubmodelElement? Value { get; set; }

/// <summary>
/// Iterate over all the class instances referenced from this instance
Expand Down Expand Up @@ -10037,7 +10038,7 @@ public T Transform<TContext, T>(
return transformer.TransformOperationVariable(this, context);
}

public OperationVariable(ISubmodelElement value)
public OperationVariable(ISubmodelElement? value)
{
Value = value;
}
Expand Down Expand Up @@ -12097,12 +12098,12 @@ public interface IEmbeddedDataSpecification : IClass
/// <summary>
/// Reference to the data specification
/// </summary>
public IReference DataSpecification { get; set; }
public IReference? DataSpecification { get; set; }

/// <summary>
/// Actual content of the data specification
/// </summary>
public IDataSpecificationContent DataSpecificationContent { get; set; }
public IDataSpecificationContent? DataSpecificationContent { get; set; }
}

/// <summary>
Expand All @@ -12113,12 +12114,12 @@ public class EmbeddedDataSpecification : IEmbeddedDataSpecification
/// <summary>
/// Reference to the data specification
/// </summary>
public IReference DataSpecification { get; set; }
public IReference? DataSpecification { get; set; }

/// <summary>
/// Actual content of the data specification
/// </summary>
public IDataSpecificationContent DataSpecificationContent { get; set; }
public IDataSpecificationContent? DataSpecificationContent { get; set; }

/// <summary>
/// Iterate over all the class instances referenced from this instance
Expand Down Expand Up @@ -12194,8 +12195,8 @@ public T Transform<TContext, T>(
}

public EmbeddedDataSpecification(
IReference dataSpecification,
IDataSpecificationContent dataSpecificationContent)
IReference? dataSpecification,
IDataSpecificationContent? dataSpecificationContent)
{
DataSpecification = dataSpecification;
DataSpecificationContent = dataSpecificationContent;
Expand Down Expand Up @@ -12591,7 +12592,7 @@ public interface IValueReferencePair : IClass
/// <remarks>
/// It is recommended to use a global reference.
/// </remarks>
public IReference ValueId { get; set; }
public IReference? ValueId { get; set; }
}

/// <summary>
Expand All @@ -12611,7 +12612,7 @@ public class ValueReferencePair : IValueReferencePair
/// <remarks>
/// It is recommended to use a global reference.
/// </remarks>
public IReference ValueId { get; set; }
public IReference? ValueId { get; set; }

/// <summary>
/// Iterate over all the class instances referenced from this instance
Expand Down Expand Up @@ -12678,7 +12679,7 @@ public T Transform<TContext, T>(

public ValueReferencePair(
string? value,
IReference valueId)
IReference? valueId)
{
Value = value;
ValueId = valueId;
Expand Down
6 changes: 3 additions & 3 deletions src/AasCore.Aas3_0/verification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ Aas.DataTypeDefXsd valueType
/// Check that the target of the model reference matches the <paramref name="expectedType" />.
/// </summary>
public static bool IsModelReferenceTo(
IReference reference,
IReference? reference,
KeyTypes expectedType
)
{
Expand All @@ -1973,7 +1973,7 @@ KeyTypes expectedType
/// Check that the target of the reference matches a <see cref="Aas.Constants.AasReferables" />.
/// </summary>
public static bool IsModelReferenceToReferable(
IReference reference
IReference? reference
)
{
return reference.Type == ReferenceTypes.ModelReference
Expand Down Expand Up @@ -9615,7 +9615,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString(
/// <param name="that">
/// The instance of the meta-model to be verified
/// </param>
public static IEnumerable<Reporting.Error> Verify(Aas.IClass that)
public static IEnumerable<Reporting.Error> Verify(IClass? that)
{
foreach (var error in _transformer.Transform(that))
{
Expand Down
Loading

0 comments on commit 6daf0f7

Please sign in to comment.