Skip to content

Commit 2745a35

Browse files
authored
Merge branch 'develop-6.0' into spike/remove-iscopednode
2 parents 9c0f146 + 930fb98 commit 2745a35

File tree

47 files changed

+1011
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1011
-260
lines changed

src/Hl7.Fhir.Base/CompatibilitySuppressions.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,13 @@
890890
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
891891
<IsBaselineSuppression>true</IsBaselineSuppression>
892892
</Suppression>
893+
<Suppression>
894+
<DiagnosticId>CP0002</DiagnosticId>
895+
<Target>M:Hl7.Fhir.Model.Canonical.CanonicalUriForFhirCoreType(System.String)</Target>
896+
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
897+
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
898+
<IsBaselineSuppression>true</IsBaselineSuppression>
899+
</Suppression>
893900
<Suppression>
894901
<DiagnosticId>CP0002</DiagnosticId>
895902
<Target>M:Hl7.Fhir.Model.Date.op_Equality(Hl7.Fhir.Model.Date,Hl7.Fhir.Model.Date)</Target>
@@ -2563,6 +2570,13 @@
25632570
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
25642571
<IsBaselineSuppression>true</IsBaselineSuppression>
25652572
</Suppression>
2573+
<Suppression>
2574+
<DiagnosticId>CP0002</DiagnosticId>
2575+
<Target>M:Hl7.Fhir.Model.Canonical.CanonicalUriForFhirCoreType(System.String)</Target>
2576+
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
2577+
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
2578+
<IsBaselineSuppression>true</IsBaselineSuppression>
2579+
</Suppression>
25662580
<Suppression>
25672581
<DiagnosticId>CP0002</DiagnosticId>
25682582
<Target>M:Hl7.Fhir.Model.Date.op_Equality(Hl7.Fhir.Model.Date,Hl7.Fhir.Model.Date)</Target>

src/Hl7.Fhir.Base/Introspection/ModelInspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ private void extractBackbonesFromClasses(IEnumerable<Type> classTypes)
290290

291291
#region IModelInfo
292292

293-
public Canonical? CanonicalUriForFhirCoreType(string typeName) => Canonical.CanonicalUriForFhirCoreType(typeName);
293+
public Canonical? CanonicalUriForFhirCoreType(string typeName) => Canonical.ForCoreType(typeName);
294294

295295
public Canonical? CanonicalUriForFhirCoreType(Type type) => GetFhirTypeNameForType(type) is { } name ? CanonicalUriForFhirCoreType(name) : null;
296296

src/Hl7.Fhir.Base/Model/Canonical.cs

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
/*
22
Copyright (c) 2011+, HL7, Inc.
33
All rights reserved.
4-
5-
Redistribution and use in source and binary forms, with or without modification,
4+
5+
Redistribution and use in source and binary forms, with or without modification,
66
are permitted provided that the following conditions are met:
7-
8-
* Redistributions of source code must retain the above copyright notice, this
7+
8+
* Redistributions of source code must retain the above copyright notice, this
99
list of conditions and the following disclaimer.
10-
* Redistributions in binary form must reproduce the above copyright notice,
11-
this list of conditions and the following disclaimer in the documentation
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
1212
and/or other materials provided with the distribution.
13-
* Neither the name of HL7 nor the names of its contributors may be used to
14-
endorse or promote products derived from this software without specific
13+
* Neither the name of HL7 nor the names of its contributors may be used to
14+
endorse or promote products derived from this software without specific
1515
prior written permission.
16-
17-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20-
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21-
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22-
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23-
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24-
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25-
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2626
POSSIBILITY OF SUCH DAMAGE.
27-
27+
2828
*/
2929

30-
using P=Hl7.Fhir.ElementModel.Types;
30+
using P = Hl7.Fhir.ElementModel.Types;
3131
using Hl7.Fhir.Utility;
32+
using Hl7.Fhir.Rest;
3233
using System;
3334

3435
#nullable enable
@@ -37,6 +38,11 @@ namespace Hl7.Fhir.Model;
3738

3839
public partial class Canonical
3940
{
41+
/// <summary>
42+
/// The base uri for FHIR core profiles, which is "http://hl7.org/fhir/StructureDefinition/".
43+
/// </summary>
44+
public static readonly Uri FHIR_CORE_PROFILE_BASE_URI = new(ResourceIdentity.CORE_BASE_URL);
45+
4046
/// <summary>
4147
/// Constructs a Canonical based on a given <see cref="Uri"/>.
4248
/// </summary>
@@ -46,20 +52,19 @@ public Canonical(Uri uri) : this(uri.OriginalString)
4652
// nothing
4753
}
4854

49-
/// <summary>
50-
/// Constructs a canonical from its components.
51-
/// </summary>
52-
public Canonical(string? uri, string? version, string? fragment = null)
53-
{
54-
if ((uri is not null) && uri.IndexOfAny(['|', '#']) != -1)
55-
throw Error.Argument(nameof(uri), "cannot contain version/fragment data");
56-
57-
if ((version is not null) && version.IndexOfAny(['|', '#']) != -1)
58-
throw Error.Argument(nameof(version), "cannot contain version/fragment data");
55+
/// <summary>
56+
/// Constructs a canonical from its components.
57+
/// </summary>
58+
public Canonical(string? uri, string? version, string? fragment = null)
59+
{
60+
if ((uri is not null) && uri.IndexOfAny(['|', '#']) != -1)
61+
throw Error.Argument(nameof(uri), "cannot contain version/fragment data");
5962

60-
if ((fragment is not null) && fragment.IndexOfAny(['|', '#']) != -1)
61-
throw Error.Argument(nameof(fragment), "already contains version/fragment data");
63+
if ((version is not null) && version.IndexOfAny(['|', '#']) != -1)
64+
throw Error.Argument(nameof(version), "cannot contain version/fragment data");
6265

66+
if ((fragment is not null) && fragment.IndexOfAny(['|', '#']) != -1)
67+
throw Error.Argument(nameof(fragment), "already contains version/fragment data");
6368

6469
Value = uri +
6570
(version is not null ? "|" + version : null) +
@@ -80,7 +85,7 @@ public void Deconstruct(out string? uri, out string? version, out string? fragme
8085
/// Converts a string to a canonical.
8186
/// </summary>
8287
/// <param name="value"></param>
83-
public static implicit operator Canonical(string value) => new(value);
88+
public static implicit operator Canonical(string? value) => new(value);
8489

8590
/// <summary>
8691
/// Converts a canonical to a string.
@@ -93,9 +98,17 @@ public void Deconstruct(out string? uri, out string? version, out string? fragme
9398
/// </summary>
9499
public static bool IsValidValue(string value) => FhirUri.IsValidValue(value);
95100

96-
public static readonly Uri FHIR_CORE_PROFILE_BASE_URI = new(@"http://hl7.org/fhir/StructureDefinition/");
97-
public static Canonical CanonicalUriForFhirCoreType(string typename) => new(FHIR_CORE_PROFILE_BASE_URI + typename);
98-
101+
/// <summary>
102+
/// Constructs a Canonical to represent a FHIR core type given by name.
103+
/// </summary>
104+
/// <remarks>If the typename is an absolute url, this function assumes the
105+
/// typename is already fully qualified and will return a canonical with that value.
106+
/// </remarks>
107+
public static Canonical ForCoreType(string typename)
108+
{
109+
var typeNameUri = new Canonical(typename);
110+
return typeNameUri.IsAbsolute ? typeNameUri : ResourceIdentity.Core(typename).OriginalString;
111+
}
99112

100113
/// <summary>
101114
/// The version string of the canonical (if present).
@@ -145,8 +158,8 @@ private static (string? url, string? version, string? fragment) splitCanonical(s
145158
if (url.EndsWith(separator.ToString())) url = url[..^1];
146159
var position = url.LastIndexOf(separator);
147160

148-
return position == -1 ?
149-
(url, null)
161+
return position == -1
162+
? (url, null)
150163
: (url[..position], url[(position + 1)..]);
151164
}
152165
}
@@ -157,8 +170,8 @@ private static (string? url, string? version, string? fragment) splitCanonical(s
157170
/// <exception cref="InvalidOperationException">The value of this canonical is null,
158171
/// which is not valid for System strings.</exception>
159172
public P.String ToSystemString() => (P.String?)TryConvertToSystemTypeInternal() ??
160-
throw new InvalidOperationException("Value is null.");
173+
throw new InvalidOperationException("Value is null.");
161174

162175
protected internal override P.Any? TryConvertToSystemTypeInternal() =>
163-
Value is not null ? new P.String(Value) : null;
176+
Value is not null ? new P.String(Value) : null;
164177
}

0 commit comments

Comments
 (0)