Skip to content

Commit

Permalink
Merge pull request #2939 from FirelyTeam/6.0/2930-remove-isnested-type
Browse files Browse the repository at this point in the history
2930 Clean up IsNested/BackboneType attribute information
  • Loading branch information
Kasdejong authored Oct 23, 2024
2 parents 581baec + be68c7b commit f530fdd
Show file tree
Hide file tree
Showing 592 changed files with 28,614 additions and 6,450 deletions.
84 changes: 84 additions & 0 deletions src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Introspection.BackboneTypeAttribute</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Runtime.CompilerServices.CollectionBuilderAttribute</Target>
Expand All @@ -21,6 +28,13 @@
<Right>lib/netstandard2.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Introspection.BackboneTypeAttribute</Target>
<Left>lib/netstandard2.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.ElementModel.TypedElementExtensions.IsExactlyEqualTo``1(``0,``0,System.Boolean)</Target>
Expand Down Expand Up @@ -98,6 +112,41 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.ClassMapping.get_DefinitionPath</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.FhirTypeAttribute.get_IsNestedType</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.FhirTypeAttribute.get_IsResource</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.FhirTypeAttribute.set_IsNestedType(System.Boolean)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.FhirTypeAttribute.set_IsResource(System.Boolean)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Model.Parameters.get_Item(System.String)</Target>
Expand Down Expand Up @@ -231,6 +280,41 @@
<Right>lib/netstandard2.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.ClassMapping.get_DefinitionPath</Target>
<Left>lib/netstandard2.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.FhirTypeAttribute.get_IsNestedType</Target>
<Left>lib/netstandard2.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.FhirTypeAttribute.get_IsResource</Target>
<Left>lib/netstandard2.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.FhirTypeAttribute.set_IsNestedType(System.Boolean)</Target>
<Left>lib/netstandard2.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.FhirTypeAttribute.set_IsResource(System.Boolean)</Target>
<Left>lib/netstandard2.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Model.Parameters.get_Item(System.String)</Target>
Expand Down
35 changes: 0 additions & 35 deletions src/Hl7.Fhir.Base/Introspection/BackboneTypeAttribute.cs

This file was deleted.

14 changes: 2 additions & 12 deletions src/Hl7.Fhir.Base/Introspection/ClassMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,13 @@ public static bool TryCreate(Type type, [NotNullWhen(true)]out ClassMapping? res
// Now continue with the normal algorithm, types adorned with the [FhirTypeAttribute]
if (GetAttribute<FhirTypeAttribute>(type.GetTypeInfo(), release) is not { } typeAttribute) return false;

var backboneAttribute = GetAttribute<BackboneTypeAttribute>(type, release);

result = new ClassMapping(collectTypeName(typeAttribute, type), type, release)
{
IsResource = typeAttribute.IsResource || type.CanBeTreatedAsType(typeof(Resource)),
IsResource = type.CanBeTreatedAsType(typeof(Resource)),
IsCodeOfT = ReflectionHelper.IsClosedGenericType(type) &&
ReflectionHelper.IsConstructedFromGenericTypeDefinition(type, typeof(Code<>)),
IsFhirPrimitive = typeof(PrimitiveType).IsAssignableFrom(type),
IsBackboneType = typeAttribute.IsNestedType || backboneAttribute is not null,
DefinitionPath = backboneAttribute?.DefinitionPath,
IsBackboneType = typeAttribute.IsBackboneType,
IsBindable = GetAttribute<BindableAttribute>(type.GetTypeInfo(), release)?.IsBindable ?? false,
Canonical = typeAttribute.Canonical,
ValidationAttributes = GetAttributes<ValidationAttribute>(type.GetTypeInfo(), release).ToArray(),
Expand Down Expand Up @@ -173,13 +170,6 @@ private ClassMapping(string name, Type nativeType, FhirRelease release)
/// </summary>
public bool IsBackboneType { get; private set; } = false;


/// <summary>
/// If this is a backbone type (<see cref="IsBackboneType"/>), then this contains the path
/// in the StructureDefinition where the backbone was defined first.
/// </summary>
public string? DefinitionPath { get; private set; }

/// <summary>
/// Indicates whether this class can be used for binding.
/// </summary>
Expand Down
19 changes: 6 additions & 13 deletions src/Hl7.Fhir.Base/Introspection/FhirTypeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace Hl7.Fhir.Introspection
/// <summary>
/// This attribute is applied to classes that represent FHIR datatypes and resources.
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class FhirTypeAttribute : VersionedAttribute
{
public FhirTypeAttribute(string name)
Expand All @@ -57,20 +57,13 @@ public FhirTypeAttribute(string name, string canonical)
public string Name { get; private set; }

/// <summary>
/// Indicates whether this class represents the nested complex type for a (backbone) element.
/// </summary>
public bool IsNestedType { get; set; }

/// <summary>
/// Indicates whether this class represents a Resource
/// The canonical of the StructureDefinition defining this type.
/// </summary>
public bool IsResource { get; set; }
public string? Canonical { get; set; }

/// <summary>
/// The canonical of the StructureDefinition defining this type.
/// Indicates whether this class represents the nested complex type for a (backbone) element.
/// </summary>
public string? Canonical { get; set; }
public bool IsBackboneType { get; set; }
}
}

#nullable restore
}
2 changes: 1 addition & 1 deletion src/Hl7.Fhir.Base/Model/Generated/Binary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Hl7.Fhir.Model
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Binary","http://hl7.org/fhir/StructureDefinition/Binary", IsResource=true)]
[FhirType("Binary","http://hl7.org/fhir/StructureDefinition/Binary")]
public partial class Binary : Hl7.Fhir.Model.Resource
{
/// <summary>
Expand Down
27 changes: 11 additions & 16 deletions src/Hl7.Fhir.Base/Model/Generated/Bundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Hl7.Fhir.Model
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Bundle","http://hl7.org/fhir/StructureDefinition/Bundle", IsResource=true)]
[FhirType("Bundle","http://hl7.org/fhir/StructureDefinition/Bundle")]
public partial class Bundle : Hl7.Fhir.Model.Resource, IIdentifiable<Identifier>
{
/// <summary>
Expand Down Expand Up @@ -945,14 +945,13 @@ public enum HTTPVerb
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Bundle#Link", IsNestedType=true)]
[BackboneType("Bundle.link")]
[FhirType("Bundle.link", IsBackboneType=true)]
public partial class LinkComponent : Hl7.Fhir.Model.BackboneElement
{
/// <summary>
/// FHIR Type Name
/// </summary>
public override string TypeName { get { return "Bundle#Link"; } }
public override string TypeName { get { return "Bundle.link"; } }

/// <summary>
/// See http://www.iana.org/assignments/link-relations/link-relations.xhtml#link-relations-1
Expand Down Expand Up @@ -1135,14 +1134,13 @@ protected override IEnumerable<KeyValuePair<string, object>> GetElementPairs()
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Bundle#Entry", IsNestedType=true)]
[BackboneType("Bundle.entry")]
[FhirType("Bundle.entry", IsBackboneType=true)]
public partial class EntryComponent : Hl7.Fhir.Model.BackboneElement
{
/// <summary>
/// FHIR Type Name
/// </summary>
public override string TypeName { get { return "Bundle#Entry"; } }
public override string TypeName { get { return "Bundle.entry"; } }

/// <summary>
/// Links related to this entry
Expand Down Expand Up @@ -1407,14 +1405,13 @@ protected override IEnumerable<KeyValuePair<string, object>> GetElementPairs()
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Bundle#Search", IsNestedType=true)]
[BackboneType("Bundle.entry.search")]
[FhirType("Bundle.entry.search", IsBackboneType=true)]
public partial class SearchComponent : Hl7.Fhir.Model.BackboneElement
{
/// <summary>
/// FHIR Type Name
/// </summary>
public override string TypeName { get { return "Bundle#Search"; } }
public override string TypeName { get { return "Bundle.entry.search"; } }

/// <summary>
/// match | include - why this is in the result set
Expand Down Expand Up @@ -1596,14 +1593,13 @@ protected override IEnumerable<KeyValuePair<string, object>> GetElementPairs()
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Bundle#Request", IsNestedType=true)]
[BackboneType("Bundle.entry.request")]
[FhirType("Bundle.entry.request", IsBackboneType=true)]
public partial class RequestComponent : Hl7.Fhir.Model.BackboneElement
{
/// <summary>
/// FHIR Type Name
/// </summary>
public override string TypeName { get { return "Bundle#Request"; } }
public override string TypeName { get { return "Bundle.entry.request"; } }

/// <summary>
/// GET | HEAD | POST | PUT | DELETE | PATCH
Expand Down Expand Up @@ -1959,14 +1955,13 @@ protected override IEnumerable<KeyValuePair<string, object>> GetElementPairs()
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Bundle#Response", IsNestedType=true)]
[BackboneType("Bundle.entry.response")]
[FhirType("Bundle.entry.response", IsBackboneType=true)]
public partial class ResponseComponent : Hl7.Fhir.Model.BackboneElement
{
/// <summary>
/// FHIR Type Name
/// </summary>
public override string TypeName { get { return "Bundle#Response"; } }
public override string TypeName { get { return "Bundle.entry.response"; } }

/// <summary>
/// Status response code (text optional)
Expand Down
2 changes: 1 addition & 1 deletion src/Hl7.Fhir.Base/Model/Generated/DomainResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Hl7.Fhir.Model
/// </remarks>
[Serializable]
[DataContract]
[FhirType("DomainResource","http://hl7.org/fhir/StructureDefinition/DomainResource", IsResource=true)]
[FhirType("DomainResource","http://hl7.org/fhir/StructureDefinition/DomainResource")]
public abstract partial class DomainResource : Hl7.Fhir.Model.Resource, Hl7.Fhir.Model.IModifierExtendable
{
/// <summary>
Expand Down
7 changes: 3 additions & 4 deletions src/Hl7.Fhir.Base/Model/Generated/OperationOutcome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Hl7.Fhir.Model
/// </remarks>
[Serializable]
[DataContract]
[FhirType("OperationOutcome","http://hl7.org/fhir/StructureDefinition/OperationOutcome", IsResource=true)]
[FhirType("OperationOutcome","http://hl7.org/fhir/StructureDefinition/OperationOutcome")]
public partial class OperationOutcome : Hl7.Fhir.Model.DomainResource
{
/// <summary>
Expand Down Expand Up @@ -316,14 +316,13 @@ public enum IssueType
/// </remarks>
[Serializable]
[DataContract]
[FhirType("OperationOutcome#Issue", IsNestedType=true)]
[BackboneType("OperationOutcome.issue")]
[FhirType("OperationOutcome.issue", IsBackboneType=true)]
public partial class IssueComponent : Hl7.Fhir.Model.BackboneElement
{
/// <summary>
/// FHIR Type Name
/// </summary>
public override string TypeName { get { return "OperationOutcome#Issue"; } }
public override string TypeName { get { return "OperationOutcome.issue"; } }

/// <summary>
/// fatal | error | warning | information | success
Expand Down
7 changes: 3 additions & 4 deletions src/Hl7.Fhir.Base/Model/Generated/Parameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Hl7.Fhir.Model
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Parameters","http://hl7.org/fhir/StructureDefinition/Parameters", IsResource=true)]
[FhirType("Parameters","http://hl7.org/fhir/StructureDefinition/Parameters")]
public partial class Parameters : Hl7.Fhir.Model.Resource
{
/// <summary>
Expand All @@ -68,14 +68,13 @@ public partial class Parameters : Hl7.Fhir.Model.Resource
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Parameters#Parameter", IsNestedType=true)]
[BackboneType("Parameters.parameter")]
[FhirType("Parameters.parameter", IsBackboneType=true)]
public partial class ParameterComponent : Hl7.Fhir.Model.BackboneElement
{
/// <summary>
/// FHIR Type Name
/// </summary>
public override string TypeName { get { return "Parameters#Parameter"; } }
public override string TypeName { get { return "Parameters.parameter"; } }

/// <summary>
/// Name from the definition
Expand Down
2 changes: 1 addition & 1 deletion src/Hl7.Fhir.Base/Model/Generated/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Hl7.Fhir.Model
/// </remarks>
[Serializable]
[DataContract]
[FhirType("Resource","http://hl7.org/fhir/StructureDefinition/Resource", IsResource=true)]
[FhirType("Resource","http://hl7.org/fhir/StructureDefinition/Resource")]
public abstract partial class Resource : Hl7.Fhir.Model.Base
{
/// <summary>
Expand Down
Loading

0 comments on commit f530fdd

Please sign in to comment.