-
Notifications
You must be signed in to change notification settings - Fork 40
ApiCheck: Print out breaking changes to be added as exceptions #238
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
Conversation
|
@smitpatel, |
c581f07 to
a7afff3
Compare
| <_ApiListingFileSuffix Condition=" '$(_ApiListingFileSuffix)' == '' ">netcore.json</_ApiListingFileSuffix> | ||
| <_ApiListingFilePath>$(MSBuildProjectDirectory)\baseline.$(_ApiListingFileSuffix)</_ApiListingFilePath> | ||
| <_ApiExclusionsFilePath>$(MSBuildProjectDirectory)\exceptions.$(_ApiListingFileSuffix)</_ApiExclusionsFilePath> | ||
| <_ApiExclusionsFilePath>$(MSBuildProjectDirectory)\breakingchanges.$(_ApiListingFileSuffix)</_ApiExclusionsFilePath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Eilon - Though not necessary, we should change the name of exception files. We call it "exception" file at the same time we call them "exclusion" in ApiCheck source code. They are neither exception/exclusion, more like known breaking changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this sounds reasonable to me.
| } | ||
|
|
||
| public ApiComparisonResult GetDifferences() | ||
| public IList<BreakingChange> GetDifferences() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sole task or ApiListingComparer is to find differences between 2 ApiListing, removing known breaking changes should not be part of its tasks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I now see the feature remains. Only change is that this class isn't involved.
| { | ||
| breakingChanges.Add(new BreakingChange(type, "New members were added to the following interface")); | ||
| } | ||
| breakingChanges.AddRange(newMembers.Select(member => new BreakingChange(newType.Id, member.Id, ChangeKind.Addition))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part finds actually newly added members on interface (or renamed ones because they are remove/add)
|
|
||
| <PropertyGroup> | ||
| <VersionPrefix>1.0.2</VersionPrefix> | ||
| <VersionPrefix>1.0.3</VersionPrefix> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pranavkm - This version to bump?
Eilon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very nice! Just a few misc comments.
| <_ApiListingFileSuffix Condition=" '$(_ApiListingFileSuffix)' == '' ">netcore.json</_ApiListingFileSuffix> | ||
| <_ApiListingFilePath>$(MSBuildProjectDirectory)\baseline.$(_ApiListingFileSuffix)</_ApiListingFilePath> | ||
| <_ApiExclusionsFilePath>$(MSBuildProjectDirectory)\exceptions.$(_ApiListingFileSuffix)</_ApiExclusionsFilePath> | ||
| <_ApiExclusionsFilePath>$(MSBuildProjectDirectory)\breakingchanges.$(_ApiListingFileSuffix)</_ApiExclusionsFilePath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this sounds reasonable to me.
| { | ||
| breakingChanges.Add(typeChange); | ||
| } | ||
| breakingChanges.Add(new BreakingChange(type.Id, /*memberId:*/ null, ChangeKind.Removal)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can still use a named param! And then use a named param for the last param too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. in EF we use commented out if its in middle and non-commented if its last. I will change this.
| { | ||
| unchecked | ||
| { | ||
| var hashCode = TypeId.GetHashCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use https://github.com/aspnet/Common/tree/dev/shared/Microsoft.Extensions.HashCodeCombiner.Sources instead so we don't have random/arbitrary hash code combiners scattered in teh codez.
| public enum ChangeKind | ||
| { | ||
| Removal, | ||
| Modification, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+💯
| private const int Error = 1; | ||
|
|
||
| public static int Main(string[] args) | ||
| public static int Main(string [] args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢 🐼
| { | ||
| Console.WriteLine(); | ||
| Console.WriteLine(); | ||
| Console.WriteLine("Error: Following types/interfaces have one or more members removed from them."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following ...
| { | ||
| Console.WriteLine(); | ||
| Console.WriteLine(); | ||
| Console.WriteLine("Error: Following interfaces have one or more members added from them."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... added *to* them.
| { | ||
| Console.WriteLine(); | ||
| Console.WriteLine(); | ||
| Console.WriteLine("Following is the list of exclusions which are needed to be added."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following is the list of exclusions that either need to be added to the list of breaking changes, or the breaking changes themselves need to be reverted:
| Console.WriteLine( | ||
| "The process for breaking changes is described in: https://github.com/aspnet/Home/wiki/Engineering-guidelines#breaking-changes"); | ||
| Console.WriteLine( | ||
| "For how to add an exclusion to Api-check go to: https://github.com/aspnet/BuildTools/wiki/Api-Check#apicheck-exceptions"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The process to add an exclusion to this tool is described in: ...
| var change = Assert.Single(changes.BreakingChanges, bc => bc.Item.Id == "public class ComparisonScenarios.PublicToInternalClass"); | ||
| var expected = new BreakingChange( | ||
| "public class ComparisonScenarios.PublicToInternalClass", | ||
| /*memberId:*/ null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use named params instead of comments. See my earlier comment.
a7afff3 to
aff63c0
Compare
|
Updated. |
dca2620 to
ce7960e
Compare
|
Removed compact output |
| <Target Name="ApiCheck" Condition=" '$(EnableApiCheck)' == 'true' "> | ||
| <PropertyGroup> | ||
| <_ApiListingFileSuffix Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">net45.json</_ApiListingFileSuffix> | ||
| <_ApiListingFileSuffix Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">net46.json</_ApiListingFileSuffix> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Eilon - This one is bit interesting.
for .NETFramework tfm we used to use net45.json which is inconsistent now because we upgraded to net46. Though all our baselines say, net45 only. On the other side of world (in netcore/standard) anything non-net framework we used netcore (without exact version) as suffix. Should we change this one to something other than net46? Like netframework & netcore baselines?
ce7960e to
f198dcb
Compare
f198dcb to
0e914ea
Compare
| <Target Name="ApiCheck" Condition=" '$(EnableApiCheck)' == 'true' "> | ||
| <PropertyGroup> | ||
| <_ApiListingFileSuffix Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">net45.json</_ApiListingFileSuffix> | ||
| <_ApiListingFileSuffix Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">netframework.json</_ApiListingFileSuffix> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 😄
Eilon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some teeny-tiny comments, then
!
| { | ||
| if (string.IsNullOrEmpty(singleLine) || singleLine.StartsWith(" ", StringComparison.Ordinal)) | ||
| // Since tool prints out formatted list of breaking changes, | ||
| // anything that starts with Error will be considered error rest is user information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change comment: ... considered an error; the rest is ...
| if (removedTypes.Count > 0) | ||
| { | ||
| Console.WriteLine(); | ||
| Console.WriteLine("The following types/interfaces have been removed."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW types/interfaces is redundant. All interfaces are types. Can clear this up in other messages below as well.
Print out breaking changes to be added as exceptions Change format of exception files Use word breaking changes instead of exceptions/exclusions Upgrade to net46 Remove unused option of compact output.
b89e192 to
7e7ac94
Compare
| { | ||
| NullValueHandling = NullValueHandling.Ignore | ||
| })); | ||
| Console.WriteLine(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smitpatel why write anything but this block and the bit about no-longer-necessary exclusions? Everything else written to the console in this method is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is intentionally redundant.
The main task of tool is to inform the developer about breaking changes so that it can be determined if the breaking change is desired or was by mistake. We print out the list of breaking changes in a human readable format first.
The rest of parts, no-longer-necessary exceptions & json-to-add is to help user update the breaking changes file. Those JSON are not so easily readable hence redundancy.
Resolves #154 #163
Sample output:
TODO: update wiki files.
Reaction PRs:
PlatformAbstractions