Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions src/generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3421,19 +3421,36 @@ static AvailabilityBaseAttribute CloneFromOtherPlatform (AvailabilityBaseAttribu
}
}
else {
// Revision is optional, and is returned as -1 if not yet. However the Version ctor called inside the attributes throws if you pass -1 so coerse to 0
int revision = attr.Version.Revision == -1 ? 0 : attr.Version.Revision;
switch (attr.AvailabilityKind) {
case AvailabilityKind.Introduced:
return new IntroducedAttribute(platform, attr.Version.Major, attr.Version.Minor, revision, message: attr.Message);
case AvailabilityKind.Deprecated:
return new DeprecatedAttribute(platform, attr.Version.Major, attr.Version.Minor, revision, message: attr.Message);
case AvailabilityKind.Obsoleted:
return new ObsoletedAttribute(platform, attr.Version.Major, attr.Version.Minor, revision, message: attr.Message);
case AvailabilityKind.Unavailable:
return new UnavailableAttribute(platform, message: attr.Message);
default:
throw new NotImplementedException ();
// Due to the absurd API of Version, you can not pass a -1 to the revision constructor
// nor can you coerse to 0, as that will fail with "16.0.0 <= 16.0" => false in the registrar

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's a back port. coerse -> coerce

// So determine if the revision is -1, and use the 2 or 3 param ctor...
if (attr.Version.Revision == -1) {
switch (attr.AvailabilityKind) {
case AvailabilityKind.Introduced:
return new IntroducedAttribute(platform, attr.Version.Major, attr.Version.Minor, message: attr.Message);
case AvailabilityKind.Deprecated:
return new DeprecatedAttribute(platform, attr.Version.Major, attr.Version.Minor, message: attr.Message);
case AvailabilityKind.Obsoleted:
return new ObsoletedAttribute(platform, attr.Version.Major, attr.Version.Minor, message: attr.Message);
case AvailabilityKind.Unavailable:
return new UnavailableAttribute(platform, message: attr.Message);
default:
throw new NotImplementedException ();
}
}
else {
switch (attr.AvailabilityKind) {
case AvailabilityKind.Introduced:
return new IntroducedAttribute(platform, attr.Version.Major, attr.Version.Minor, attr.Version.Revision, message: attr.Message);
case AvailabilityKind.Deprecated:
return new DeprecatedAttribute(platform, attr.Version.Major, attr.Version.Minor, attr.Version.Revision, message: attr.Message);
case AvailabilityKind.Obsoleted:
return new ObsoletedAttribute(platform, attr.Version.Major, attr.Version.Minor, attr.Version.Revision, message: attr.Message);
case AvailabilityKind.Unavailable:
return new UnavailableAttribute(platform, message: attr.Message);
default:
throw new NotImplementedException ();
}
}
}
}
Expand Down