Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generator] Do not zero-extend implied catalyst attributes #15648

Merged
merged 2 commits into from
Aug 8, 2022
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
// 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