Skip to content

Commit 1384e22

Browse files
committed
Updates to OData model change analyzer
1 parent 0197e89 commit 1384e22

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

ODataModelChangeAnalyzer/ODataModelChangeAnalyzer/Changes.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ record SchemaElementRemoved(IEdmElement Target) : IModelChange
1717
public ChangeKind ChangeKind => ChangeKind.Deletion;
1818
}
1919

20-
record StructuredTypeChangedFromOpenToClose(IEdmElement Target, IEdmElement Original) : IModelChange
20+
record StructuredTypeChangedFromOpenToClose(IEdmStructuredType NewType, IEdmStructuredType OriginalType) : IModelChange
2121
{
22+
public IEdmElement Target => NewType;
2223
public ChangeKind ChangeKind => ChangeKind.Modification;
2324
}
2425

ODataModelChangeAnalyzer/ODataModelChangeAnalyzer/Program.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@
2222
Console.WriteLine(change);
2323
Console.WriteLine($"At line: {location!.LineNumber} pos: {location!.LinePosition}");
2424
Console.WriteLine();
25+
26+
var error = change switch
27+
{
28+
StructuredTypeChangedFromOpenToClose c => $"Changing the type {c.NewType.FullTypeName()} from open to close is a breaking change. To fix this, add the attribute OpenType=\"True\".",
29+
_ => throw new NotSupportedException()
30+
};
2531
}
2632

2733
Console.WriteLine($"\nFound {count} changes.");
2834

2935

36+
37+
3038
IEdmModel ReadModel(string path)
3139
{
3240
using var file = File.OpenRead(path);
@@ -35,4 +43,6 @@ IEdmModel ReadModel(string path)
3543
return model;
3644
}
3745

38-
record ChangeWithLocation(object Change, CsdlLocation? Location);
46+
record ChangeWithLocation(object Change, CsdlLocation? Location);
47+
48+
record ConditionalBreakingChange<T>(Func<T, bool> IsBreaking);

ODataModelChangeAnalyzer/ODataModelChangeAnalyzer/TripPinUpdatedModel.csdl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
1+
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0" xmlns:ags="http://aggregator.microsoft.com/internal">
22
<script/>
33
<edmx:DataServices>
4-
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Microsoft.OData.SampleService.Models.TripPin">
4+
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Microsoft.OData.SampleService.Models.TripPin" xmlns:ags="http://aggregator.microsoft.com/internal">
55
<EnumType Name="PersonGender">
66
<Member Name="Male" Value="0"/>
77
<Member Name="Female" Value="1"/>
88
<Member Name="Unknown" Value="2"/>
99
</EnumType>
10-
<ComplexType Name="City">
10+
<ComplexType Name="City" ags:IsHidden="True">
1111
<Property Name="CountryRegion" Type="Edm.String" Nullable="false"/>
1212
<Property Name="Name" Type="Edm.String" Nullable="false"/>
1313
<Property Name="Region" Type="Edm.String" Nullable="false"/>

0 commit comments

Comments
 (0)