8000 [ApiDiff] Implementation of the new ApiDiff that reuses GenAPI features by carlossanlop · Pull Request #46425 · dotnet/sdk · GitHub
[go: up one dir, main page]

Skip to content

[ApiDiff] Implementation of the new ApiDiff that reuses GenAPI features #46425

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

Merged
merged 71 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
2d1dc61
ApiDiff implementation
carlossanlop Feb 1, 2025
36fd38d
Resources
carlossanlop Feb 1, 2025
1cc4d22
Tests
carlossanlop Feb 1, 2025
80b53ef
Some infra files
carlossanlop Feb 1, 2025
7ac8c16
Address some of the feedback
carlossanlop Feb 3, 2025
bd88b38
Move the IO code to the business layer. Add a test that verifies the …
carlossanlop Feb 4, 2025
e0f9553
Address most of the feedback
carlossanlop Feb 6, 2025
9590165
Exclude diffplex DLLs from signing
carlossanlop Feb 6, 2025
c2d59aa
Fix markdown file title handling.
carlossanlop Feb 7, 2025
3e3bd44
Exclude from source build.
carlossanlop Feb 7, 2025
0027749
Allow overriding attribute list, add tests.
carlossanlop Feb 7, 2025
2c41297
improve attribute comment
carlossanlop Feb 7, 2025
6bbeb12
Add tests for implicit and explicit operators.
carlossanlop Feb 7, 2025
480696f
Implement API exclusion. Add tests.
carlossanlop Feb 7, 2025
33d3585
Remove Microsoft.CodeAnalysis.Worskpaces.Common PackageVersion from t…
carlossanlop Feb 13, 2025
9722f23
Unskip the checked tests.
carlossanlop Feb 13, 2025
edc45a9
Add exception resource strings, make some methods static, ignore newl…
carlossanlop Feb 18, 2025
91f2228
fix the resources error
carlossanlop Feb 19, 2025
a347588
Make some code async. Add option to exclude assemblies. Add tests.
carlossanlop Feb 21, 2025
223195b
Suppress additional diagnostics by default
carlossanlop Feb 27, 2025
5cad5e5
New resource
carlossanlop Feb 27, 2025
2bc7e7c
Fix bugs in attributes and events, add tests
carlossanlop Feb 27, 2025
b50eca1
remove static
carlossanlop Feb 27, 2025
6e12987
Add event tests
carlossanlop Feb 27, 2025
7422840
Support attributes that take arguments, add tests.
carlossanlop Feb 27, 2025
ebd0248
Truly async
carlossanlop Feb 27, 2025
8576cc7
Fix bug with abstract events where the field event declaration needs …
carlossanlop Feb 27, 2025
06d74b3
Add test that confirms that no files are getting overwritten when mul…
carlossanlop Feb 27, 2025
80232b7
Add arguments for before and after friendly name, separate that from …
carlossanlop Feb 28, 2025
befe4c6
Remove the body from methods and properties as requested in API diff PR.
carlossanlop Mar 4, 2025
7923d93
Add unchanged assembly and unchanged namespace tests.
carlossanlop Mar 5, 2025
364ec5c
Add destructor tests.
carlossanlop Mar 5, 2025
a4fbd5f
Add field list tests.
carlossanlop Mar 5, 2025
005d45e
Add an Options class for CSharpAssemblyDocumentGenerator to avoid gro…
carlossanlop Mar 5, 2025
265d10f
Moved some code from the generator to rewriters. Much faster.
carlossanlop Mar 6, 2025
b8829d4
Split test files into smaller ones
carlossanlop Mar 7, 2025
a9da515
Fix bug in TypeDeclarationCSharpSyntaxRewriter causing an extra space…
carlossanlop Mar 7, 2025
969358b
cons string t in AttributeNameSuffixRemover
carlossanlop Mar 7, 2025
09d06de
Fix bug in GlobalPrefixRemover preventing the removal of just global …
carlossanlop Mar 7, 2025
d4ef227
Fix bug in primitive conversion rewriter preventing the correct visit…
carlossanlop Mar 7, 2025
704507c
Fix bugs in body removal rewriter in accesors, operators and records
carlossanlop Mar 7, 2025
dc2d806
Add code specific for records in memory generator. Move the most debu…
carlossanlop Mar 7, 2025
e5eb224
Revert the TypeDeclarationCSharpSyntaxRewriter changes, they were wro…
carlossanlop Mar 7, 2025
21a1ecd
Don't truncate the attribute name, leave the type name full.
carlossanlop Mar 7, 2025
c6fdf8f
missing comments
carlossanlop Mar 14, 2025
ea4cbde
Missing docs
carlossanlop Mar 14, 2025
3ddb52c
Missing docs
carlossanlop Mar 14, 2025
9b5d333
Move private member under public ones
carlossanlop Mar 14, 2025
49dffe0
Replace the WaitAll with actual async method calls.
carlossanlop Mar 14, 2025
6c7cb26
Better split of code
carlossanlop Mar 14, 2025
62078f7
Fix sdk.sln merge conflict
carlossanlop Mar 25, 2025
5b4ef0a
Add enum support. Fix minor bug with records with members.
carlossanlop Mar 27, 2025
eb98ae9
Fix bug preventing attributes with arguments from getting either supp…
carlossanlop Mar 28, 2025
7810d71
Shorter test names.
8000 carlossanlop Mar 28, 2025
d1e46e5
Yet one more attribute bug fix and test.
carlossanlop Mar 28, 2025
942de97
Use ExternalCertificateId to sign DiffPlex dependencies.
carlossanlop Apr 7, 2025
92f306c
Address UI feedback.
carlossanlop Apr 7, 2025
8eaa8c9
Take lists of files with elements to exclude, instead of directly pas…
carlossanlop Apr 8, 2025
7446164
Add missing case for including interface members.
carlossanlop Apr 8, 2025
2241b38
Merge remote-tracking branch 'dotnet/main' into ApiDiff
carlossanlop Apr 24, 2025
b4d4d47
Solve merge confict in sdk.sln
carlossanlop Apr 24, 2025
c27086d
System.CommandLine override no longer needed.
carlossanlop Apr 24, 2025
3d7e841
Delete launchSettings.json
carlossanlop Apr 25, 2025
a5fe497
Update System.CommandLine usage to match latest version's API surface.
carlossanlop Apr 25, 2025
970ca19
test typo
carlossanlop Apr 25, 2025
27ca575
No resources needed yet
carlossanlop Apr 25, 2025
373eb30
Remove Required from optioNTableOfContentsTitle
carlossanlop Apr 25, 2025
37203a0
Set IsShippingPackage to false
carlossanlop Apr 25, 2025
2f050e3
The default attributes to exclude list should only apply to the ApiDi…
carlossanlop Apr 25, 2025
0c8b15a
Delete xlfs
carlossanlop Apr 25, 2025
dc02b78
Merge branch 'main' into ApiDiff
carlossanlop Apr 28, 2025
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
Prev Previous commit
Next Next commit
Take lists of files with elements to exclude, instead of directly pas…
…sing list of elements to exclude.
  • Loading branch information
carlossanlop committed Apr 8, 2025
commit 8eaa8c9b9ebb3dca575b401f53e1517a2b7d580c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ internal class GenAPIDiffConfigurationBinder : BinderBase<DiffConfiguration>
private readonly Option<string> _optionBeforeFriendlyName;
private readonly Option<string> _optionAfterFriendlyName;
private readonly Option<string> _optionTableOfContentsTitle;
private readonly Option<string[]?> _optionAssembliesToExclude;
private readonly Option<string[]?> _optionAttributesToExclude;
private readonly Option<string[]?> _optionApisToExclude;
private readonly Option<FileInfo[]?> _optionFilesWithAssembliesToExclude;
private readonly Option<FileInfo[]?> _optionFilesWithAttributesToExclude;
private readonly Option<FileInfo[]?> _optionFilesWithApisToExclude;
private readonly Option<bool> _optionAddPartialModifier;
private readonly Option<bool> _optionAttachDebugger;

Expand All @@ -31,9 +31,9 @@ internal GenAPIDiffConfigurationBinder(Option<string> optionBeforeAssembliesFold
Option<string> optionBeforeFriendlyName,
Option<string> optionAfterFriendlyName,
Option<string> optionTableOfContentsTitle,
Option<string[]?> optionAssembliesToExclude,
Option<string[]?> optionAttributesToExclude,
Option<string[]?> optionApisToExclude,
Option<FileInfo[]?> optionFilesWithAssembliesToExclude,
Option<FileInfo[]?> optionFilesWithAttributesToExclude,
Option<FileInfo[]?> optionFilesWithApisToExclude,
Option<bool> optionAddPartialModifier,
Option<bool> optionAttachDebugger)
{
Expand All @@ -45,9 +45,9 @@ internal GenAPIDiffConfigurationBinder(Option<string> optionBeforeAssembliesFold
_optionBeforeFriendlyName = optionBeforeFriendlyName;
_optionAfterFriendlyName = optionAfterFriendlyName;
_optionTableOfContentsTitle = optionTableOfContentsTitle;
_optionAssembliesToExclude = optionAssembliesToExclude;
_optionAttributesToExclude = optionAttributesToExclude;
_optionApisToExclude = optionApisToExclude;
_optionFilesWithAssembliesToExclude = optionFilesWithAssembliesToExclude;
_optionFilesWithAttributesToExclude = optionFilesWithAttributesToExclude;
_optionFilesWithApisToExclude = optionFilesWithApisToExclude;
_optionAddPartialModifier = optionAddPartialModifier;
_optionAttachDebugger = optionAttachDebugger;
}
Expand All @@ -62,9 +62,9 @@ protected override DiffConfiguration GetBoundValue(BindingContext bindingContext
BeforeFriendlyName: bindingContext.ParseResult.GetValueForOption(_optionBeforeFriendlyName) ?? throw new NullReferenceException("Null before friendly name"),
AfterFriendlyName: bindingContext.ParseResult.GetValueForOption(_optionAfterFriendlyName) ?? throw new NullReferenceException("Null after friendly name"),
TableOfContentsTitle: bindingContext.ParseResult.GetValueForOption(_optionTableOfContentsTitle) ?? throw new NullReferenceException("Null table of contents title"),
AssembliesToExclude: bindingContext.ParseResult.GetValueForOption(_optionAssembliesToExclude),
AttributesToExclude: bindingContext.ParseResult.GetValueForOption(_optionAttributesToExclude),
ApisToExclude: bindingContext.ParseResult.GetValueForOption(_optionApisToExclude),
FilesWithAssembliesToExclude: bindingContext.ParseResult.GetValueForOption(_optionFilesWithAssembliesToExclude),
FilesWithAttributesToExclude: bindingContext.ParseResult.GetValueForOption(_optionFilesWithAttributesToExclude),
FilesWithApisToExclude: bindingContext.ParseResult.GetValueForOption(_optionFilesWithApisToExclude),
AddPartialModifier: bindingContext.ParseResult.GetValueForOption(_optionAddPartialModifier),
AttachDebugger: bindingContext.ParseResult.GetValueForOption(_optionAttachDebugger)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@ public static async Task Main(string[] args)
IsRequired = true
Copy link
Member

Choose a reason for hiding this comment

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

Seems we could have a default for a lot of these things? For instance if a single assembly were passed in we could probably come up with reasonable defaults. Might be interesting to improve a lighter-weight "happy path"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I think I could use a simple default and make this argument optional. The powershell script we use for the monthly api diffs will continue passing a value relevant to the diff comparison being done.

Copy link
Member

Choose a reason for hiding this comment

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

Parameter is still marked as required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

};

Option<string[]?> optionAssembliesToExclude = new(["--assembliesToExclude", "-eas"], () => null)
Option<FileInfo[]?> optionFilesWithAssembliesToExclude = new(["--assembliesToExclude", "-eas"], () => null)
{
Description = "Assemblies from both before and after to exclude from the diff.",
Description = "An optional array of filepaths, each containing a list of assemblies that should be excluded from the diff. Each file should contain one assembly name per line, with no extensions.",
Arity = ArgumentArity.ZeroOrMore,
IsRequired = false,
};

Option<string[]?> optionAttributesToExclude = new(["--attributesToExclude", "-eattrs"], () => null)
Option<FileInfo[]?> optionFilesWithAttributesToExclude = new(["--attributesToExclude", "-eattrs"], () => null)
{
Description = "Attributes to exclude from the diff.",
Description = "An optional array of filepaths, each containing a list of attributes to exclude from the diff. Each file should contain one API full name per line.",
Arity = ArgumentArity.ZeroOrMore,
IsRequired = false
};

Option<string[]?> optionApisToExclude = new(["--apisToExclude", "-eapis"], () => null)
Option<FileInfo[]?> optionFilesWithApisToExclude = new(["--apisToExclude", "-eapis"], () => null)
{
Description = "APIs to exclude from the diff.",
Description = "An optional array of filepaths, each containing a list of APIs to exclude from the diff. Each file should contain one API full name per line.",
Arity = ArgumentArity.ZeroOrMore,
IsRequired = false
};
Expand All @@ -113,9 +113,9 @@ public static async Task Main(string[] args)
rootCommand.Add(optionBeforeFriendlyName);
rootCommand.Add(optionAfterFriendlyName);
rootCommand.Add(optionTableOfContentsTitle);
rootCommand.Add(optionAssembliesToExclude);
rootCommand.Add(optionAttributesToExclude);
rootCommand.Add(optionApisToExclude);
rootCommand.Add(optionFilesWithAssembliesToExclude);
rootCommand.Add(optionFilesWithAttributesToExclude);
rootCommand.Add(optionFilesWithApisToExclude);
rootCommand.Add(optionAddPartialModifier);
rootCommand.Add(optionAttachDebugger);

Expand All @@ -127,9 +127,9 @@ public static async Task Main(string[] args)
optionBeforeFriendlyName,
optionAfterFriendlyName,
optionTableOfContentsTitle,
optionAssembliesToExclude,
optionAttributesToExclude,
optionApisToExclude,
optionFilesWithAssembliesToExclude,
optionFilesWithAttributesToExclude,
optionFilesWithApisToExclude,
optionAddPartialModifier,
optionAttachDebugger);

Expand All @@ -141,9 +141,9 @@ private static Task HandleCommandAsync(DiffConfiguration diffConfig)
{
var log = new ConsoleLog(MessageImportance.Normal);

string assembliesToExclude = string.Join(", ", diffConfig.AssembliesToExclude ?? []);
string attributesToExclude = string.Join(", ", diffConfig.AttributesToExclude ?? []);
string apisToExclude = string.Join(", ", diffConfig.ApisToExclude ?? []);
string assembliesToExclude = string.Join(", ", diffConfig.FilesWithAssembliesToExclude?.Select(a => a.FullName) ?? []);
string attributesToExclude = string.Join(", ", diffConfig.FilesWithAttributesToExclude?.Select(a => a.FullName) ?? []);
string apisToExclude = string.Join(", ", diffConfig.FilesWithApisToExclude?.Select(a => a.FullName) ?? []);

// Custom ordering to match help menu.
log.LogMessage("Selected options:");
Expand All @@ -152,9 +152,9 @@ private static Task HandleCommandAsync(DiffConfiguration diffConfig)
log.LogMessage($" - 'Before' reference assemblies: {diffConfig.BeforeAssemblyReferencesFolderPath}");
log.LogMessage($" - 'After' reference assemblies: {diffConfig.AfterAssemblyReferencesFolderPath}");
log.LogMessage($" - Output: {diffConfig.OutputFolderPath}");
log.LogMessage($" - Assemblies to exclude: {assembliesToExclude}");
log.LogMessage($" - Attributes to exclude: {attributesToExclude}");
log.LogMessage($" - APIs to exclude: {apisToExclude}");
log.LogMessage($" - Files with assemblies to exclude: {assembliesToExclude}");
log.LogMessage($" - Files with attributes to exclude: {attributesToExclude}");
log.LogMessage($" - Files with APIs to exclude: {apisToExclude}");
log.LogMessage($" - 'Before' friendly name: {diffConfig.BeforeFriendlyName}");
log.LogMessage($" - 'After' friendly name: {diffConfig.AfterFriendlyName}");
log.LogMessage($" - Table of contents title: {diffConfig.TableOfContentsTitle}");
Expand All @@ -176,9 +176,9 @@ private static Task HandleCommandAsync(DiffConfiguration diffConfig)
diffConfig.BeforeFriendlyName,
diffConfig.AfterFriendlyName,
diffConfig.TableOfContentsTitle,
diffConfig.AssembliesToExclude,
diffConfig.AttributesToExclude,
diffConfig.ApisToExclude,
diffConfig.FilesWithAssembliesToExclude,
diffConfig.FilesWithAttributesToExclude,
diffConfig.FilesWithApisToExclude,
diffConfig.AddPartialModifier,
writeToDisk: true,
diagnosticOptions: null // TODO: If needed, add CLI option to pass specific diagnostic options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public record DiffConfiguration(
string BeforeFriendlyName,
string AfterFriendlyName,
string TableOfContentsTitle,
string[]? AssembliesToExclude,
string[]? AttributesToExclude,
string[]? ApisToExclude,
FileInfo[]? FilesWithAssembliesToExclude,
FileInfo[]? FilesWithAttributesToExclude,
FileInfo[]? FilesWithApisToExclude,
bool AddPartialModifier,
bool AttachDebugger
);
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public static class DiffGeneratorFactory
/// <param name="beforeFriendlyName">The friendly name for the assemblies before the change.</param>
/// <param name="afterFriendlyName">The friendly name for the assemblies after the change.</param>
/// <param name="tableOfContentsTitle">The title for the table of contents in the generated diff.</param>
/// <param name="assembliesToExclude">An optional list of assemblies to avoid showing in the diff. If <see langword="null"/>, no assemblies are excluded.</param>
/// <param name="attributesToExclude">An optional list of attributes to avoid showing in the diff. If <see langword="null"/>, the default list of attributes to exclude <see cref="DiffGeneratorFactory.DefaultAttributesToExclude"/> is used. If an empty list, no attributes are excluded.</param>
/// <param name="apisToExclude">An optional list of APIs to avoid showing in the diff.</param>
/// <param name="filesWithAssembliesToExclude">An optional array of filepaths each containing a list of assemblies to avoid showing in the diff. If <see langword="null"/>, no assemblies are excluded.</param>
/// <param name="filesWithAttributesToExclude">An optional array of filepaths each containing a list of attributes to avoid showing in the diff. If <see langword="null"/>, the default list of attributes to exclude <see cref="DiffGeneratorFactory.DefaultAttributesToExclude"/> is used. If an empty list, no attributes are excluded.</param>
/// <param name="filesWithApisToExclude">An optional array of filepaths each containing a list of APIs to avoid showing in the diff.</param>
/// <param name="addPartialModifier">Indicates whether to add the partial modifier to types.</param>
/// <param name="writeToDisk">If <see langword="true"/>, when calling <see cref="IDiffGenerator.RunAsync"/>, the generated markdown files get written to disk, and no item is added to the <see cref="IDiffGenerator.RunAsync"/> dictionary. If <see langword="false"/>, when calling <see cref="IDiffGenerator.RunAsync"/>, the generated markdown files get added to the <see cref="IDiffGenerator.RunAsync"/> dictionary (with the file path as the dictionary key) and none of them is written to disk. This is meant for testing purposes.</param>
/// <param name="diagnosticOptions">An optional list of diagnostic options to use when generating the diff.</param>
Expand All @@ -59,9 +59,9 @@ public static IDiffGenerator Create(ILog log,
string beforeFriendlyName,
string afterFriendlyName,
string tableOfContentsTitle,
string[]? assembliesToExclude,
string[]? attributesToExclude,
string[]? apisToExclude,
FileInfo[]? filesWithAssembliesToExclude,
FileInfo[]? filesWithAttributesToExclude,
FileInfo[]? filesWithApisToExclude,
bool addPartialModifier,
bool writeToDisk,
IEnumerable<KeyValuePair<string, ReportDiagnostic>>? diagnosticOptions = null)
Expand All @@ -75,9 +75,9 @@ public static IDiffGenerator Create(ILog log,
beforeFriendlyName,
afterFriendlyName,
tableOfContentsTitle,
assembliesToExclude,
attributesToExclude,
apisToExclude,
filesWithAssembliesToExclude,
filesWithAttributesToExclude,
filesWithApisToExclude,
addPartialModifier,
writeToDisk,
diagnosticOptions);
Expand Down
Loading
Loading
0