This commit is contained in:
Jérôme Laban 2019-02-24 23:22:42 -05:00
Коммит af548535bf
23 изменённых файлов: 1594 добавлений и 0 удалений

223
.editorconfig Normal file
Просмотреть файл

@ -0,0 +1,223 @@
root = true
[*]
end_of_line = crlf
tab_width = 4
trim_trailing_whitespace = true
insert_final_newline = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_block_contents
csharp_indent_block_contents = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_braces
csharp_indent_braces = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_case_contents
csharp_indent_case_contents = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_labels
csharp_indent_labels = one_less_than_current
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_indent_switch_labels
csharp_indent_switch_labels = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_catch
csharp_new_line_before_catch = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_else
csharp_new_line_before_else = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_finally
csharp_new_line_before_finally = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_members_in_anonymous_types
csharp_new_line_before_members_in_anonymous_types = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_members_in_object_initializers
csharp_new_line_before_members_in_object_initializers = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_before_open_brace
csharp_new_line_before_open_brace = all
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_new_line_between_query_expression_clauses
csharp_new_line_between_query_expression_clauses = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_prefer_braces
csharp_prefer_braces = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_prefer_simple_default_expression
csharp_prefer_simple_default_expression = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_preserve_single_line_blocks
csharp_preserve_single_line_blocks = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_preserve_single_line_statements
csharp_preserve_single_line_statements = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_cast
csharp_space_after_cast = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_colon_in_inheritance_clause
csharp_space_after_colon_in_inheritance_clause = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_comma
csharp_space_after_comma = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_dot
csharp_space_after_dot = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_keywords_in_control_flow_statements
csharp_space_after_keywords_in_control_flow_statements = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_after_semicolon_in_for_statement
csharp_space_after_semicolon_in_for_statement = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_around_binary_operators
csharp_space_around_binary_operators = before_and_after
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_around_declaration_statements
csharp_space_around_declaration_statements = do_not_ignore
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_colon_in_inheritance_clause
csharp_space_before_colon_in_inheritance_clause = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_comma
csharp_space_before_comma = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_dot
csharp_space_before_dot = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_open_square_brackets
csharp_space_before_open_square_brackets = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_before_semicolon_in_for_statement
csharp_space_before_semicolon_in_for_statement = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_empty_square_brackets
csharp_space_between_empty_square_brackets = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_call_empty_parameter_list_parentheses
csharp_space_between_method_call_empty_parameter_list_parentheses = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_call_name_and_opening_parenthesis
csharp_space_between_method_call_name_and_opening_parenthesis = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_call_parameter_list_parentheses
csharp_space_between_method_call_parameter_list_parentheses = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_declaration_empty_parameter_list_parentheses
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_declaration_name_and_open_parenthesis
csharp_space_between_method_declaration_name_and_open_parenthesis = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_method_declaration_parameter_list_parentheses
csharp_space_between_method_declaration_parameter_list_parentheses = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_parentheses
csharp_space_between_parentheses = none
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_space_between_square_brackets
csharp_space_between_square_brackets = false
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_conditional_delegate_call
csharp_style_conditional_delegate_call = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_accessors
csharp_style_expression_bodied_accessors = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_constructors
csharp_style_expression_bodied_constructors = false:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_indexers
csharp_style_expression_bodied_indexers = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_methods
csharp_style_expression_bodied_methods = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_operators
csharp_style_expression_bodied_operators = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_expression_bodied_properties
csharp_style_expression_bodied_properties = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_inlined_variable_declaration
csharp_style_inlined_variable_declaration = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_pattern_matching_over_as_with_null_check
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_pattern_matching_over_is_with_cast_check
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_throw_expression
csharp_style_throw_expression = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_var_elsewhere
csharp_style_var_elsewhere = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_var_for_built_in_types
csharp_style_var_for_built_in_types = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#csharp_style_var_when_type_is_apparent
csharp_style_var_when_type_is_apparent = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_sort_system_directives_first
dotnet_sort_system_directives_first = true
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_coalesce_expression
dotnet_style_coalesce_expression = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_collection_initializer
dotnet_style_collection_initializer = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_explicit_tuple_names
dotnet_style_explicit_tuple_names = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_null_propagation
dotnet_style_null_propagation = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_object_initializer
dotnet_style_object_initializer = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_predefined_type_for_locals_parameters_members
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_predefined_type_for_member_access
dotnet_style_predefined_type_for_member_access = false:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_qualification_for_event
dotnet_style_qualification_for_event = false:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_qualification_for_field
dotnet_style_qualification_for_field = false:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_qualification_for_method
dotnet_style_qualification_for_method = false:suggestion
# http://kent-boogaart.com/blog/editorconfig-reference-for-c-developers#dotnet_style_qualification_for_property
dotnet_style_qualification_for_property = false:suggestion
[{*.xaml, *.xml, *.targets, *.props}]
indent_style = tab
[{*.cs, *.tt}]
indent_style = tab
[{*.ts, *.json}]
indent_style = tab
[*.csproj]
indent_style = tab
tab_width = 2
indent_size = 2
[*.js]
indent_style = space
[*.yml]
indent_style = space
[*.md]
indent_style = space

39
.github/ISSUE_TEMPLATE.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,39 @@
<!--
PLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.
ISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.
-->
## I'm submitting a...
<!-- Please uncomment one or more that apply to this issue -->
<!-- - Regression (a behavior that used to work and stopped working in a new release) -->
<!-- - Bug report (I searched for similar issues and did not find one) -->
<!-- - Feature request -->
<!-- - Sample app request -->
<!-- - Documentation issue or request -->
<!-- - Question of Support request => Please do not submit support request here, instead see https://github.com/nventive/Uno.Core/blob/master/Readme.md#have-questions-feature-requests-issues -->
## Current behavior
<!-- Describe how the issue manifests. -->
## Expected behavior
<!-- Describe what the desired behavior would be. -->
## Minimal reproduction of the problem with instructions
<!--
For bug reports please provide a *MINIMAL REPRO PROJECT* and the *STEPS TO REPRODUCE*
-->
## Environment
<!-- For bug reports Check one or more of the following options with "x" -->
```
Package Version(s):
Visual Studio
- [ ] 2017 (version: )
- [ ] 2017 Preview (version: )
- [ ] for Mac (version: )
```

41
.github/PULL_REQUEST_TEMPLATE.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,41 @@
GitHub Issue (If applicable): #
<!-- Link to relevant GitHub issue if applicable. All PRs should be associated with an issue (GitHub issue or internal) -->
## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one ore more that apply to this PR -->
<!-- - Bugfix -->
<!-- - Feature -->
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Other... Please describe: -->
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
## What is the new behavior?
<!-- Please describe the new behavior after your modifications. -->
## PR Checklist
Please check if your PR fulfills the following requirements:
- [ ] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [ ] Contains **NO** breaking changes
- [ ] Associated with an issue (GitHub or internal)
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below.
Please note that breaking changes are likely to be rejected -->
## Other information
<!-- Please provide any additional information if necessary -->
Internal Issue (If applicable):
<!-- Link to relevant internal issue if applicable. All PRs should be associated with an issue (GitHub issue or internal) -->

235
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,235 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# Remove everything beginning with a dot
.*/
!.github/
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
launchSettings.json
# Build results
[Dd]ebug[-\w]*/
[Dd]ebugPublic/
[Rr]elease[-\w]*/
[Rr]eleases/
[Xx]64/
[Xx]86/
# [Bb]uild/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.mdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.binlog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# DotCover is a Code Coverage Tool
*.dotCover
# MightyMoose
*.mm.*
AutoTest.Net/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Un-comment the next line if you do not want to checkin
# your web deploy settings because they may include unencrypted
# passwords
#*.pubxml
*.publishproj
# NuGet Packages
#*.nupkg
# The packages folder can be ignored because of Package Restore
#**/packages/*
# except build/, which is used as an MSBuild target.
#!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/
# Xamarin Android
Resource.Designer.cs
*.bak
*/nuget_version_override.txt
/src/crosstargeting_override.props
/build/tools/**
!build/tools/packages.config
/build/*.nupkg

3
CODE_OF_CONDUCT.md Normal file
Просмотреть файл

@ -0,0 +1,3 @@
# Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).

69
CONTRIBUTING.md Normal file
Просмотреть файл

@ -0,0 +1,69 @@
# How to contribute
There are lots of ways to contribute to the Uno Core and we appreciate the help from the community. You can provide feedback, report bugs, give suggestions, contribute code, and participate in the platform discussions.
## Code of conduct
To better foster an open, innovative and inclusive community please refer to our [Code of Conduct](CODE_OF_CONDUCT.md) when contributing.
### Report a bug
If you think you've found a bug, please log a new issue in the [Uno Core GitHub issue tracker](https://github.com/nventive/Uno.Core/issues). When filing issues, please use our [bug filing template](.github/ISSUE_TEMPLATE.md).
The best way to get your bug fixed is to be as detailed as you can be about the problem.
Providing a minimal project with steps to reproduce the problem is ideal.
Here are questions you can answer before you file a bug to make sure you're not missing any important information.
1. Did you read the [documentation](https://github.com/nventive/Uno.Core/blob/master/doc)?
2. Did you include the snippet of broken code in the issue?
3. What are the *EXACT* steps to reproduce this problem?
4. What specific version or build are you using?
5. What operating system are you using?
GitHub supports [markdown](https://help.github.com/articles/github-flavored-markdown/), so when filing bugs make sure you check the formatting before clicking submit.
### Make a suggestion
If you have an idea for a new feature or enhancement let us know by filing an [issue](https://github.com/nventive/Uno.Core/issues). To help us understand and prioritize your idea please provide as much detail about your scenario and why the feature or enhancement would be useful.
### Ask questions
If you have a question be sure to first checkout our [documentation](https://github.com/nventive/Uno.Core/blob/master/doc). But if you are still stuck, you'll have a better chance of getting help on [StackOverflow](https://stackoverflow.com/questions/tagged/uno-platform) and we'll do our best to answer it. Questions asked there should be tagged with `uno-platform`.
For a more direct conversation, [our gitter is also a good place to visit](https://gitter.im/uno-platform/Lobby).
## Contributing code and content
The Uno Platform is an open source project and we welcome code and content contributions from the community.
**Identifying the scale**
If you would like to contribute to one of our repositories, first identify the scale of what you would like to contribute. If it is small (grammar/spelling or a bug fix) feel free to start working on a fix.
If you are submitting a feature or substantial code contribution, please discuss it with the team. You might also read these two blogs posts on contributing code: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don't "Push" Your Pull Requests](https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik. Note that all code submissions will be rigorously reviewed and tested by the Uno Platform team, and only those that meet an extremely high bar for both quality and design/roadmap appropriateness will be merged into the source.
**Obtaining the source code**
If you are an outside contributer, please fork the Uno Core repository you would like to contribute to your account. See the GitHub documentation for [forking a repo](https://help.github.com/articles/fork-a-repo/) if you have any questions about this.
**Submitting a pull request**
If you don't know what a pull request is read this article: https://help.github.com/articles/using-pull-requests. Make sure the respository can build and all tests pass, as well as follow the current coding guidelines.
Pull requests should all be done to the **master** branch.
**Commit/Pull Request Format**
```
Summary of the changes (Less than 80 chars)
- Detail 1
- Detail 2
Addresses #bugnumber (in this specific format)
```
**Tests**
- Tests need to be provided for every bug/feature that is completed.
- Tests only need to be present for issues that need to be verified by QA (e.g. not tasks)
- If there is a scenario that is far too hard to test there does not need to be a test for it.
- "Too hard" is determined by the team as a whole.

209
License.md Normal file
Просмотреть файл

@ -0,0 +1,209 @@
# Uno.Core
Copyright (c) nventive
All rights reserved.
# Apache 2.0 License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

20
README.md Normal file
Просмотреть файл

@ -0,0 +1,20 @@
# NuGet Package Diffing Tool
A command line tool that compares two versions of a NuGet package and provides public API differences.
This tool has originally been built to fail a build when a breaking change is detected, using a
published nuget package (in nuget.org) and a local NuGet package.
## Installing
Run the following command from commandline (requires .NET Core 2.1 installed):
```
dotnet tool install --global Uno.PackageDiff
```
## Diffing packages
```
generatepkgdiff --base=Uno.UI --other=C:\temp\Uno.UI.1.43.0-PullRequest0621.917.nupkg --outfile=diff.md
```

21
gitversion.yml Normal file
Просмотреть файл

@ -0,0 +1,21 @@
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
next-version: 1.26.0
continuous-delivery-fallback-tag: ""
branches:
master:
tag: dev
increment: none
beta:
tag: beta
increment: none
(stable):
tag:
increment: none
dev/.*?/(.*?):
tag: dev.{BranchName}
projects/(.*?):
tag: proj-{BranchName}
increment: none
ignore:
sha: []

43
src/Directory.Build.props Normal file
Просмотреть файл

@ -0,0 +1,43 @@
<Project ToolsVersion="15.0">
<PropertyGroup>
<DebugType>portable</DebugType>
<DebugSymbols>True</DebugSymbols>
<RepositoryUrl>$(BUILD_REPOSITORY_URI)</RepositoryUrl>
<Copyright>nventive</Copyright>
<Author>nventive</Author>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<!-- Version management is now done through NuGet, this avoids issues related version mismatch -->
<Version>255.255.255.255</Version>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<DefaultLanguage>en-US</DefaultLanguage>
<UnoSourceGeneratorUseGenerationHost>true</UnoSourceGeneratorUseGenerationHost>
</PropertyGroup>
<PropertyGroup>
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
<IsSampleProject>$(MSBuildProjectName.Contains('Sample'))</IsSampleProject>
</PropertyGroup>
<Choose>
<When Condition="'$(Configuration)' != 'Debug' and '$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false' and '$(IsSampleProject)' != 'true'">
<PropertyGroup>
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager to the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Optional: Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-62925-02" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-62925-02" PrivateAssets="All"/>
</ItemGroup>
</When>
</Choose>
</Project>

Просмотреть файл

@ -0,0 +1,3 @@
<Project ToolsVersion="15.0">
</Project>

Просмотреть файл

@ -0,0 +1,57 @@
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mono.Cecil;
namespace Uno.PackageDiff.Tests
{
[TestClass]
public class Given_AssemblyComparer
{
private (AssemblyDefinition baseAssembly, AssemblyDefinition targetAssembly) BuildAssemblies([CallerMemberName] string testName = null)
{
var baseFile = GetType().Assembly.GetManifestResourceNames().FirstOrDefault(f => f.Contains(testName + ".base.cs"));
var targetFile = GetType().Assembly.GetManifestResourceNames().FirstOrDefault(f => f.Contains(testName + ".target.cs"));
return (BuildDefinition(baseFile), BuildDefinition(targetFile));
}
AssemblyDefinition BuildDefinition(string name)
{
using(var s = new StreamReader(this.GetType().Assembly.GetManifestResourceStream(name)))
{
return ModuleBuilder.BuildAssemblyDefinition(s.ReadToEnd());
}
}
[TestMethod]
public void When_EmptyAssembly()
{
var (baseAssembly, targetAssembly) = BuildAssemblies();
var r = AssemblyComparer.CompareTypes(baseAssembly, targetAssembly);
Assert.AreEqual(0, r.InvalidTypes.Length);
Assert.AreEqual(0, r.InvalidEvents.Length);
Assert.AreEqual(0, r.InvalidFields.Length);
Assert.AreEqual(0, r.InvalidMethods.Length);
Assert.AreEqual(0, r.InvalidProperties.Length);
}
[TestMethod]
public void When_Target_MissingProperty()
{
var (baseAssembly, targetAssembly) = BuildAssemblies();
var r = AssemblyComparer.CompareTypes(baseAssembly, targetAssembly);
Assert.AreEqual(0, r.InvalidTypes.Length);
Assert.AreEqual(0, r.InvalidEvents.Length);
Assert.AreEqual(0, r.InvalidFields.Length);
Assert.AreEqual(2, r.InvalidMethods.Length);
Assert.AreEqual(1, r.InvalidProperties.Length);
Assert.AreEqual("MyProperty", r.InvalidProperties.First().Name);
}
}
}

Просмотреть файл

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Host;
namespace Uno.PackageDiff.Tests
{
static class ModuleBuilder
{
public static Mono.Cecil.AssemblyDefinition BuildAssemblyDefinition(string sourceCode)
{
var st = SyntaxFactory.ParseCompilationUnit(sourceCode);
var compilation = CSharpLanguage.Instance
.CreateLibraryCompilation(assemblyName: "InMemoryAssembly", enableOptimisations: false)
.AddSyntaxTrees(new[] { st.SyntaxTree });
var stream = new MemoryStream();
var emitResult = compilation.Emit(stream);
stream.Position = 0;
return Mono.Cecil.AssemblyDefinition.ReadAssembly(stream);
}
public class CSharpLanguage : ILanguageService
{
private readonly IEnumerable<MetadataReference> _references;
public static CSharpLanguage Instance { get; } = new CSharpLanguage();
private readonly MetadataReference CorlibReference =
MetadataReference.CreateFromFile(typeof(object).Assembly.Location);
private readonly MetadataReference ConsoleReference =
MetadataReference.CreateFromFile(typeof(System.Console).Assembly.Location);
private readonly MetadataReference DecimalReference =
MetadataReference.CreateFromFile(typeof(System.Decimal).Assembly.Location);
private readonly MetadataReference SystemCoreReference =
MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location);
private readonly MetadataReference CodeAnalysisReference =
MetadataReference.CreateFromFile(typeof(Compilation).Assembly.Location);
private CSharpLanguage()
{
var sdkFiles = this.GetType().Assembly.GetManifestResourceNames().Where(f => f.Contains("mono_sdk"));
_references = new[] {
CorlibReference,
ConsoleReference,
DecimalReference,
SystemCoreReference,
CodeAnalysisReference,
};
}
public Compilation CreateLibraryCompilation(string assemblyName, bool enableOptimisations)
{
var options = new CSharpCompilationOptions(
OutputKind.DynamicallyLinkedLibrary,
optimizationLevel: OptimizationLevel.Release,
allowUnsafe: true)
// Disabling concurrent builds allows for the emit to finish.
.WithConcurrentBuild(false)
;
return CSharpCompilation.Create(assemblyName, options: options, references: _references);
}
}
}
}

Просмотреть файл

@ -0,0 +1 @@


Просмотреть файл

@ -0,0 +1 @@


Просмотреть файл

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Uno.PackageDiff.Tests.Sources
{
public class When_Target_MissingProperty
{
public int MyProperty { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Uno.PackageDiff.Tests.Sources
{
public class When_Target_MissingProperty
{
}
}

Просмотреть файл

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Sources/**/*.cs" />
<None Include="Sources/**/*.cs" />
<EmbeddedResource Include="Sources/**/*.cs" />
<EmbeddedResource Include="Sources/**/*.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
<PackageReference Include="Mono.Cecil" Version="0.10.3" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.8.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Uno.PackageDiff\Uno.PackageDiff.csproj" />
</ItemGroup>
</Project>

31
src/Uno.PackageDiff.sln Normal file
Просмотреть файл

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28516.95
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Uno.PackageDiff", "Uno.PackageDiff\Uno.PackageDiff.csproj", "{629D2B8F-14BC-4FAB-B660-E677A6C68EAF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Uno.PackageDiff.Tests", "Uno.PackageDiff.Tests\Uno.PackageDiff.Tests.csproj", "{B0DB1166-738C-4E74-AB68-8123E5283D76}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{629D2B8F-14BC-4FAB-B660-E677A6C68EAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{629D2B8F-14BC-4FAB-B660-E677A6C68EAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{629D2B8F-14BC-4FAB-B660-E677A6C68EAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{629D2B8F-14BC-4FAB-B660-E677A6C68EAF}.Release|Any CPU.Build.0 = Release|Any CPU
{B0DB1166-738C-4E74-AB68-8123E5283D76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0DB1166-738C-4E74-AB68-8123E5283D76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0DB1166-738C-4E74-AB68-8123E5283D76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0DB1166-738C-4E74-AB68-8123E5283D76}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {68050057-5CDC-451F-BDD7-71AC6CBD4862}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Mono.Cecil;
namespace Uno.PackageDiff
{
public class ComparisonResult
{
public ComparisonResult(TypeDefinition[] invalidTypes,
PropertyDefinition[] invalidProperties,
MethodDefinition[] invalidMethods,
FieldDefinition[] invalidFields,
EventDefinition[] invalidEvents)
{
InvalidTypes = invalidTypes;
InvalidProperties = invalidProperties;
InvalidMethods = invalidMethods;
InvalidFields = invalidFields;
InvalidEvents = invalidEvents;
}
public TypeDefinition[] InvalidTypes { get; }
public PropertyDefinition[] InvalidProperties { get; }
public MethodDefinition[] InvalidMethods { get; }
public FieldDefinition[] InvalidFields { get; }
public EventDefinition[] InvalidEvents { get; }
}
public class AssemblyComparer
{
public static ComparisonResult CompareTypes(AssemblyDefinition baseAssembly, AssemblyDefinition targetAssembly)
{
var baseTypes = baseAssembly.MainModule.GetTypes();
var targetTypes = targetAssembly.MainModule.GetTypes();
// Types only in target
var q = from targetType in baseTypes
where !targetTypes.Any(t => t.FullName == targetType.FullName)
where targetType.IsPublic
select targetType;
var invalidTypes = q.ToArray();
var existingTypes = (
from targetType in baseTypes
let sourceType = targetTypes.FirstOrDefault(t => t.FullName == targetType.FullName)
where sourceType != null
where targetType.IsPublic
select (sourceType, targetType)
).ToArray();
var invalidProperties = FindMissingProperties(existingTypes);
var invalidMethods = FindMissingMethods(existingTypes);
var invalidFields = FindMissingFields(existingTypes);
var invalidEvents = FindMissingEvents(existingTypes);
return new ComparisonResult(invalidTypes, invalidProperties, invalidMethods, invalidFields, invalidEvents);
}
private static MethodDefinition[] FindMissingMethods(IEnumerable<(TypeDefinition sourceType, TypeDefinition targetType)> existingTypes)
{
IEnumerable<string> getMethodParamsSignature(MethodDefinition method)
=> method.Parameters.Select(p => p.Name + p.ParameterType.FullName);
var q1 = from type in existingTypes
from targetMethod in type.targetType.Methods
let targetMethodParams = getMethodParamsSignature(targetMethod)
where targetMethod.IsPublic
where !type.sourceType.Methods.Any(m => m.Name == targetMethod.Name && targetMethodParams.SequenceEqual(getMethodParamsSignature(m)))
select targetMethod;
return q1.ToArray();
}
private static string ExpandMethod(MethodDefinition method)
{
var parms = string.Join(", ", method.Parameters.Select(p => $"{p.ParameterType} {p.Name}"));
return $"{method.ReturnType} {method.DeclaringType}.{method.Name}({parms})";
}
private static EventDefinition[] FindMissingEvents(IEnumerable<(TypeDefinition sourceType, TypeDefinition targetType)> existingTypes)
{
var q1 = from type in existingTypes
from targetEvent in type.targetType.Events
where targetEvent.AddMethod?.IsPublic ?? false
where !type.sourceType.Events.Any(p => p.Name == targetEvent.Name && p.EventType.FullName != targetEvent.FullName)
select targetEvent;
return q1.ToArray();
}
private static FieldDefinition[] FindMissingFields(IEnumerable<(TypeDefinition sourceType, TypeDefinition targetType)> existingTypes)
{
var q1 = from type in existingTypes
from targetField in type.targetType.Fields
where targetField.IsPublic
where !type.sourceType.Fields.Any(p => p.Name == targetField.Name && p.FieldType.FullName == targetField.FieldType.FullName)
select targetField;
return q1.ToArray();
}
private static PropertyDefinition[] FindMissingProperties(IEnumerable<(TypeDefinition sourceType, TypeDefinition targetType)> existingTypes)
{
var q1 = from type in existingTypes
from targetProp in type.targetType.Properties
where targetProp.GetMethod?.IsPublic ?? false
where !type.sourceType.Properties.Any(p => p.Name == targetProp.Name && p.PropertyType.FullName == targetProp.PropertyType.FullName)
select targetProp;
return q1.ToArray();
}
}
}

Просмотреть файл

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
namespace Uno.PackageDiff
{
[DataContract(Name = "DiffIgnore", Namespace = "")]
public class DiffIgnore
{
public IgnoreSet[] IgnoreSets { get; set; }
}
[DataContract(Name = "IgnoreSet", Namespace = "")]
public class IgnoreSet
{
[DataMember()]
public string BaseVersion { get; set; }
[DataMember()]
public string[] Properties { get; set; }
[DataMember()]
public string[] Methods { get; set; }
[DataMember()]
public string[] Fields { get; set; }
[DataMember()]
public string[] Events { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,289 @@
using Mono.Cecil;
using Mono.Options;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Packaging;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Uno.PackageDiff
{
class Program
{
private static readonly PackageSource NuGetOrgSource = new PackageSource("https://api.nuget.org/v3/index.json");
static async Task<int> Main(string[] args)
{
string sourceArgument = null;
string targetArgument = null;
string outputFile = null;
string diffIgnoreFile = null;
var p = new OptionSet() {
{ "base=", s => sourceArgument = s },
{ "other=", s => targetArgument = s },
{ "outfile=", s => outputFile = s },
{ "diffignore=", s => diffIgnoreFile = s },
};
p.Parse(args);
var source = await GetPackage(sourceArgument);
var target = await GetPackage(targetArgument);
try
{
var sourcePlatforms = Directory.GetDirectories(Path.Combine(source.path, "lib"), "*.*", SearchOption.TopDirectoryOnly);
var targetPlatforms = Directory.GetDirectories(Path.Combine(target.path, "lib"), "*.*", SearchOption.TopDirectoryOnly);
var platformsFiles = from sourceAssemblyPath in sourcePlatforms
join targetAssemblyPath in targetPlatforms on Path.GetFileName(sourceAssemblyPath) equals Path.GetFileName(targetAssemblyPath)
select new
{
Platform = Path.GetFileName(sourceAssemblyPath),
Source = sourceAssemblyPath,
Target = targetAssemblyPath
};
var ignoreSet = ParseDiffIgnore(diffIgnoreFile, source.nuspecReader.GetVersion().ToString());
using (var writer = new StreamWriter(outputFile))
{
writer.WriteLine($"Comparison report for {source.nuspecReader.GetId()} **{source.nuspecReader.GetVersion()}** with {target.nuspecReader.GetId()} **{target.nuspecReader.GetVersion()}**");
foreach(var platform in platformsFiles)
{
writer.WriteLine($"# {platform.Platform} Platform");
foreach (var sourceFile in Directory.GetFiles(platform.Source, "*.dll"))
{
var targetFile = Path.Combine(platform.Target, Path.GetFileName(sourceFile));
Console.WriteLine($"Comparing {sourceFile} and {targetFile}");
CompareAssemblies(writer, sourceFile, targetFile);
}
}
}
Console.WriteLine($"Done comparing.");
return 0;
}
finally
{
Directory.Delete(source.path, true);
Directory.Delete(target.path, true);
}
}
public static void CompareAssemblies(StreamWriter writer, string sourceFile, string targetFile)
{
using(var source = ReadModule(sourceFile))
using(var target = ReadModule(targetFile))
{
writer.WriteLine($"## {Path.GetFileName(sourceFile)}");
var results = AssemblyComparer.CompareTypes(source, target);
ReportMissingTypes(writer, results);
ReportMethods(writer, results);
ReportEvents(writer, results);
ReportFields(writer, results);
ReportProperties(writer, results);
}
}
private static void ReportMissingTypes(StreamWriter writer, ComparisonResult results)
{
writer.WriteLine("### {0} missing types:", results.InvalidTypes.Length);
foreach(var invalidType in results.InvalidTypes)
{
writer.WriteLine("\t* `{0}`", invalidType.FullName);
}
}
private static void ReportProperties(StreamWriter writer, ComparisonResult results)
{
var groupedProperties = from method in results.InvalidProperties
group method by method.DeclaringType.FullName into types
select types;
writer.WriteLine("### {0} missing or changed properties in existing types:", results.InvalidProperties.Length);
foreach(var updatedType in groupedProperties)
{
writer.WriteLine("- `{0}`", updatedType.Key);
foreach(var property in updatedType)
{
writer.WriteLine("\t* ``{0}``", property);
}
}
}
private static void ReportFields(StreamWriter writer, ComparisonResult results)
{
var groupedFields = from method in results.InvalidFields
group method by method.DeclaringType.FullName into types
select types;
writer.WriteLine("### {0} missing or changed fields in existing types:", results.InvalidFields.Length);
foreach(var updatedType in groupedFields)
{
writer.WriteLine("- `{0}`", updatedType.Key);
foreach(var field in updatedType)
{
writer.WriteLine("\t* ``{0}``", field);
}
}
}
private static void ReportMethods(StreamWriter writer, ComparisonResult results)
{
var groupedMethods = from method in results.InvalidMethods
group method by method.DeclaringType.FullName into types
select types;
writer.WriteLine("### {0} missing or changed method in existing types:", results.InvalidMethods.Length);
foreach(var updatedType in groupedMethods)
{
writer.WriteLine("- `{0}`", updatedType.Key);
foreach(var method in updatedType)
{
writer.WriteLine("\t* ``{0}``", ExpandMethod(method));
}
}
}
private static void ReportEvents(StreamWriter writer, ComparisonResult results)
{
var groupedEvents = from method in results.InvalidEvents
group method by method.DeclaringType.FullName into types
select types;
writer.WriteLine("### {0} missing or changed events in existing types:", results.InvalidEvents.Length);
foreach(var updatedType in groupedEvents)
{
writer.WriteLine("- `{0}`", updatedType.Key);
foreach(var evt in updatedType)
{
writer.WriteLine("\t* ``{0}``", evt);
}
}
}
private static string ExpandMethod(MethodDefinition method)
{
var parms = string.Join(", ", method.Parameters.Select(p => $"{p.ParameterType} {p.Name}"));
return $"{method.ReturnType} {method.DeclaringType}.{method.Name}({parms})";
}
private static AssemblyDefinition ReadModule(string path)
{
var resolver = new DefaultAssemblyResolver();
return AssemblyDefinition.ReadAssembly(path, new ReaderParameters() { AssemblyResolver = resolver });
}
private static IgnoreSet ParseDiffIgnore(string diffIgnoreFile, string baseVersion)
{
if(!string.IsNullOrEmpty(diffIgnoreFile))
{
using(var file = File.OpenRead(diffIgnoreFile))
{
var dcs = new DataContractSerializer(typeof(DiffIgnore));
var diffIgnore = (DiffIgnore)dcs.ReadObject(file);
if(diffIgnore.IgnoreSets.FirstOrDefault(s => s.BaseVersion == baseVersion) is IgnoreSet set)
{
return set;
}
}
}
return null;
}
private static async Task<(string path, NuspecReader nuspecReader)> GetPackage(string packagePath)
{
if(!packagePath.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase))
{
var settings = Settings.LoadDefaultSettings(null);
var repositoryProvider = new SourceRepositoryProvider(settings, Repository.Provider.GetCoreV3());
var repository = repositoryProvider.CreateRepository(NuGetOrgSource, FeedType.HttpV3);
var searchResource = repository.GetResource<PackageSearchResource>();
var packages = (await searchResource.SearchAsync(packagePath, new SearchFilter(true, SearchFilterType.IsLatestVersion), skip: 0, take: 1000, log: new NullLogger(), cancellationToken: CancellationToken.None)).ToArray();
if(packages.Any())
{
var latestStable = (await packages.First().GetVersionsAsync())
.OrderByDescending(v => v.Version)
.Where(v => !v.Version.IsPrerelease)
.FirstOrDefault();
if (latestStable != null)
{
var url = $"https://api.nuget.org/v3-flatcontainer/{packagePath}/{latestStable.Version}/{packagePath}.{latestStable.Version}.nupkg";
Console.WriteLine($"Downloading {url}");
var outFile = Path.GetTempFileName();
await new WebClient().DownloadFileTaskAsync(new Uri(url), outFile);
return UnpackArchive(outFile);
}
else
{
throw new InvalidOperationException($"Unable to find stable {packagePath} in {NuGetOrgSource.SourceUri}");
}
}
else
{
throw new InvalidOperationException($"Unable to find {packagePath} in {NuGetOrgSource.SourceUri}");
}
}
else
{
return UnpackArchive(packagePath);
}
}
private static (string path, NuspecReader nuspecReader) UnpackArchive(string packagePath)
{
var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString().Trim('{', '}'));
Directory.CreateDirectory(path);
Console.WriteLine($"Extracting {packagePath} -> {path}");
using (var file = File.OpenRead(packagePath))
{
using (var archive = new ZipArchive(file, ZipArchiveMode.Read))
{
archive.ExtractToDirectory(path);
}
}
if(Directory.GetFiles(path, "*.nuspec", SearchOption.AllDirectories).FirstOrDefault() is string nuspecFile)
{
return (path, new NuspecReader(nuspecFile));
}
else
{
throw new InvalidOperationException($"Unable to find nuspec file in {packagePath}");
}
}
}
}

Просмотреть файл

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<LangVersion>latest</LangVersion>
<PackAsTool>true</PackAsTool>
<ToolCommandName>generatepkgdiff</ToolCommandName>
</PropertyGroup>
<PropertyGroup>
<PackageProjectUrl>https://github.com/nventive/Uno.PackageDiff</PackageProjectUrl>
<PackageIconUrl>https://nv-assets.azurewebsites.net/logos/uno.png</PackageIconUrl>
<RepositoryUrl>https://github.com/nventive/Uno.PackageDiff</RepositoryUrl>
<Description>This package provides a nuget package diffing CLI tool.</Description>
<Copyright>Copyright (C) 2015-2019 nventive inc. - all rights reserved</Copyright>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.10.3" />
<PackageReference Include="Mono.Options" Version="5.3.0.1" />
<PackageReference Include="NuGet.Protocol" Version="4.9.3" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>