├── .editorconfig
├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .vsts-ci-steps.yml
├── .vsts-ci.yml
├── LICENSE
├── README.md
├── docfx
├── api
│ ├── .gitignore
│ └── index.md
├── articles
│ ├── toc.yml
│ └── traversal-projects-with-solutions.md
├── docfx.json
├── filterConfig.yml
├── index.md
└── toc.yml
├── docs
├── api
│ ├── Xamarin.BuildConsolidator.ILRepack.html
│ ├── Xamarin.BuildConsolidator.PackageConsolidator.html
│ ├── Xamarin.BuildConsolidator.html
│ ├── Xamarin.Downloader.Download.html
│ ├── Xamarin.Downloader.DownloadClient.DefaultOptions.html
│ ├── Xamarin.Downloader.DownloadClient.html
│ ├── Xamarin.Downloader.DownloadClientDelegate.html
│ ├── Xamarin.Downloader.DownloadStatus.html
│ ├── Xamarin.Downloader.html
│ ├── Xamarin.FileHelpers.html
│ ├── Xamarin.GuidHelpers.GuidNamespace.html
│ ├── Xamarin.GuidHelpers.html
│ ├── Xamarin.HashHelpers.html
│ ├── Xamarin.Linq.LinqExtensions.html
│ ├── Xamarin.Linq.html
│ ├── Xamarin.MSBuild.Sdk.DependencyGraph.ProjectCollectionFactory.html
│ ├── Xamarin.MSBuild.Sdk.DependencyGraph.html
│ ├── Xamarin.MSBuild.Sdk.DependencyGraphVisualizationKind.html
│ ├── Xamarin.MSBuild.Sdk.IDependencyNode.html
│ ├── Xamarin.MSBuild.Sdk.MSBuildLocator.html
│ ├── Xamarin.MSBuild.Sdk.ProjectDependencyNode.html
│ ├── Xamarin.MSBuild.Sdk.Solution.ConfigurationPlatform.html
│ ├── Xamarin.MSBuild.Sdk.Solution.SolutionBuilder.html
│ ├── Xamarin.MSBuild.Sdk.Solution.SolutionConfigurationPlatformMap.html
│ ├── Xamarin.MSBuild.Sdk.Solution.html
│ ├── Xamarin.MSBuild.Sdk.Tasks.GenerateSolution.html
│ ├── Xamarin.MSBuild.Sdk.Tasks.html
│ ├── Xamarin.MSBuild.Sdk.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFArray.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFArrayBase.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFBoolean.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFMutableArray.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFNumber.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFNumberType.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFObject.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFRange.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFString.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.CFTypeID.html
│ ├── Xamarin.NativeHelpers.CoreFoundation.html
│ ├── Xamarin.NativeHelpers.Dlfcn.html
│ ├── Xamarin.NativeHelpers.html
│ ├── Xamarin.PathHelpers.Git.html
│ ├── Xamarin.PathHelpers.Glob.html
│ ├── Xamarin.PathHelpers.html
│ ├── Xamarin.Preferences.MacUserDefaultsPreferenceStore.html
│ ├── Xamarin.Preferences.MemoryOnlyPreferenceStore.html
│ ├── Xamarin.Preferences.Preference-1.html
│ ├── Xamarin.Preferences.PreferenceChangedEventArgs.html
│ ├── Xamarin.Preferences.PreferenceStore.html
│ ├── Xamarin.Preferences.PreferenceStoreConfiguration.html
│ ├── Xamarin.Preferences.PreferenceTypeConverter-1.html
│ ├── Xamarin.Preferences.RegistryPreferenceStore.html
│ ├── Xamarin.Preferences.html
│ ├── Xamarin.ProcessControl.ConsoleRedirection.FileDescriptor.html
│ ├── Xamarin.ProcessControl.ConsoleRedirection.Segment.html
│ ├── Xamarin.ProcessControl.ConsoleRedirection.SegmentCollection.html
│ ├── Xamarin.ProcessControl.ConsoleRedirection.html
│ ├── Xamarin.ProcessControl.Exec.ExitException.html
│ ├── Xamarin.ProcessControl.Exec.ProcessRunnerHandler.html
│ ├── Xamarin.ProcessControl.Exec.html
│ ├── Xamarin.ProcessControl.ExecFlags.html
│ ├── Xamarin.ProcessControl.ExecStatus.html
│ ├── Xamarin.ProcessControl.ExecStatusEventArgs.html
│ ├── Xamarin.ProcessControl.ProcessArguments.html
│ ├── Xamarin.ProcessControl.html
│ ├── Xamarin.Security.Keychain.html
│ ├── Xamarin.Security.KeychainException.html
│ ├── Xamarin.Security.KeychainItemAlreadyExistsException.html
│ ├── Xamarin.Security.KeychainSecret.html
│ ├── Xamarin.Security.KeychainSecretName.html
│ ├── Xamarin.Security.Keychains.AppleKeychain.html
│ ├── Xamarin.Security.Keychains.DPAPIKeychain.html
│ ├── Xamarin.Security.Keychains.FileSystemKeychain.html
│ ├── Xamarin.Security.Keychains.IKeychain.html
│ ├── Xamarin.Security.Keychains.IKeychainExtensions.html
│ ├── Xamarin.Security.Keychains.ManagedProtectionKeychain.html
│ ├── Xamarin.Security.Keychains.OSKeychain.html
│ ├── Xamarin.Security.Keychains.html
│ ├── Xamarin.Security.html
│ ├── Xamarin.html
│ ├── Xunit.GB18030TestData.html
│ ├── Xunit.GB18030TestDataWithNullAndEmpty.html
│ ├── Xunit.LinuxFactAttribute.html
│ ├── Xunit.LinuxTheoryAttribute.html
│ ├── Xunit.MacFactAttribute.html
│ ├── Xunit.MacTheoryAttribute.html
│ ├── Xunit.OSFactAttribute.html
│ ├── Xunit.OSTheoryAttribute.html
│ ├── Xunit.UnixFactAttribute.html
│ ├── Xunit.UnixTheoryAttribute.html
│ ├── Xunit.WindowsFactAttribute.html
│ ├── Xunit.WindowsMacFactAttribute.html
│ ├── Xunit.WindowsMacTheoryAttribute.html
│ ├── Xunit.WindowsTheoryAttribute.html
│ ├── Xunit.html
│ ├── index.html
│ └── toc.html
├── articles
│ ├── toc.html
│ └── traversal-projects-with-solutions.html
├── favicon.ico
├── fonts
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ ├── glyphicons-halflings-regular.woff
│ └── glyphicons-halflings-regular.woff2
├── index.html
├── logo.svg
├── manifest.json
├── search-stopwords.json
├── styles
│ ├── docfx.css
│ ├── docfx.js
│ ├── docfx.vendor.css
│ ├── docfx.vendor.js
│ ├── lunr.js
│ ├── lunr.min.js
│ ├── main.css
│ ├── main.js
│ └── search-worker.js
├── toc.html
└── xrefmap.yml
├── global.json
├── mirepoix.proj
├── mirepoix.sln
├── msbuild.rsp
├── src
├── CI.props
├── Directory.Build.props
├── Directory.Build.targets
├── Version.props
├── Version.targets
├── Xamarin.BuildConsolidator.Tests
│ ├── FakeTest.cs
│ └── Xamarin.BuildConsolidator.Tests.csproj
├── Xamarin.BuildConsolidator
│ ├── FrameworkReferenceAssemblyComparer.cs
│ ├── ILRepack.cs
│ ├── ILRepackMSBuildLogger.cs
│ ├── NuGetLocalRepoHelper.cs
│ ├── PackageConsolidator.cs
│ ├── PackageConsolidatorTask.cs
│ ├── Xamarin.BuildConsolidator.csproj
│ ├── Xamarin.BuildConsolidator.targets
│ └── build
│ │ ├── Xamarin.BuildConsolidator.props
│ │ └── Xamarin.BuildConsolidator.targets
├── Xamarin.Cecil.Rocks.Tests
│ ├── MetadataVisitorTests.cs
│ └── Xamarin.Cecil.Rocks.Tests.csproj
├── Xamarin.Cecil.Rocks
│ ├── AssemblyCollection.cs
│ ├── MetadataVisitor.cs
│ ├── MetadataVisitorAcceptors.cs
│ └── Xamarin.Cecil.Rocks.csproj
├── Xamarin.Downloader.Tests
│ ├── DownloadClientTests.cs
│ └── Xamarin.Downloader.Tests.csproj
├── Xamarin.Downloader
│ ├── Download.cs
│ ├── DownloadClient.cs
│ ├── DownloadClientDelegate.cs
│ ├── DownloadStatus.cs
│ └── Xamarin.Downloader.csproj
├── Xamarin.Helpers.Tests
│ ├── FileHelperTests.cs
│ ├── GuidHelperTests.cs
│ ├── LinqExtensionsTests.cs
│ └── Xamarin.Helpers.Tests.csproj
├── Xamarin.Helpers
│ ├── FileHelpers.cs
│ ├── GuidHelpers.cs
│ ├── HashHelpers.cs
│ ├── LinqExtensions.cs
│ ├── PathHelpers.cs
│ ├── PathHelpers_Glob.cs
│ └── Xamarin.Helpers.csproj
├── Xamarin.MSBuild.Sdk.Tests
│ ├── DependencyGraphTests.cs
│ ├── MSBuildTestBase.cs
│ ├── SolutionBuilderTests.cs
│ ├── Solutions
│ │ ├── .gitignore
│ │ ├── DisabledProjectsInConfig.proj
│ │ ├── DisabledProjectsInConfig.sln
│ │ ├── FallbackToXmlForProjectGuid.proj
│ │ ├── FallbackToXmlForProjectGuid.sln
│ │ ├── Folders.proj
│ │ ├── Folders.sln
│ │ ├── NotReallyASharedProjectImportsProjitems.proj
│ │ ├── NotReallyASharedProjectImportsProjitems.sln
│ │ ├── OmitProjectFromSolution.proj
│ │ ├── OmitProjectFromSolution.sln
│ │ ├── Projects
│ │ │ ├── A.csproj
│ │ │ ├── B.csproj
│ │ │ ├── C.csproj
│ │ │ ├── FallbackToXmlForProjectGuid.csproj
│ │ │ └── InvalidSdk.csproj
│ │ ├── SharedProject
│ │ │ ├── LibraryProject
│ │ │ │ ├── LibraryProject.csproj
│ │ │ │ └── LibraryProjectClass.cs
│ │ │ ├── NotReallyASharedProjectImportsProjitems
│ │ │ │ ├── NotASharedProject.csproj
│ │ │ │ └── NotASharedProject.projitems
│ │ │ └── SharedProject
│ │ │ │ ├── SharedProject.projitems
│ │ │ │ ├── SharedProject.shproj
│ │ │ │ └── SharedProjectClass.cs
│ │ ├── SharedProjectViaExplicitShprojReference.proj
│ │ ├── SharedProjectViaExplicitShprojReference.sln
│ │ ├── SharedProjectViaTransitiveProjitemsReference.proj
│ │ ├── SharedProjectViaTransitiveProjitemsReference.sln
│ │ ├── UnsupportedProjectDependency.proj
│ │ └── UnsupportedProjectDependency.sln
│ └── Xamarin.MSBuild.Sdk.Tests.csproj
├── Xamarin.MSBuild.Sdk
│ ├── ConditionParser.cs
│ ├── DependencyGraph.cs
│ ├── DependencyGraphVisualizationKind.cs
│ ├── IDependencyNode.cs
│ ├── MSBuildLocator.cs
│ ├── ProjectDependencyNode.cs
│ ├── Resources
│ │ └── VisJsTemplate.html
│ ├── Sdk.props
│ ├── Sdk.targets
│ ├── Solution
│ │ ├── ConfigurationPlatform.cs
│ │ ├── SlnFile.cs
│ │ ├── SolutionBuilder.cs
│ │ ├── SolutionConfigurationPlatformMap.cs
│ │ ├── SolutionNode.cs
│ │ └── SolutionWriter.cs
│ ├── Tasks
│ │ ├── GenerateSolution.cs
│ │ └── PrepareConsolidationProject.cs
│ ├── VisJsGenerator.cs
│ └── Xamarin.MSBuild.Sdk.csproj
├── Xamarin.Mac.Sdk
│ ├── Sdk.props
│ ├── Sdk.targets
│ └── Xamarin.Mac.Sdk.csproj
├── Xamarin.NativeHelpers.Tests
│ ├── CoreFoundationTests.cs
│ └── Xamarin.NativeHelpers.Tests.csproj
├── Xamarin.NativeHelpers
│ ├── CoreFoundation.cs
│ ├── Dlfcn.cs
│ └── Xamarin.NativeHelpers.csproj
├── Xamarin.Preferences.Tests
│ ├── PreferenceTests.cs
│ ├── Rect.cs
│ └── Xamarin.Preferences.Tests.csproj
├── Xamarin.Preferences
│ ├── AssemblyInfo.cs
│ ├── Converters
│ │ ├── PreferenceDateTimeConverter.cs
│ │ └── PreferenceDateTimeOffsetConverter.cs
│ ├── MacUserDefaultsPreferenceStore.cs
│ ├── MemoryOnlyPreferenceStore.cs
│ ├── Preference.cs
│ ├── PreferenceChangedEventArgs.cs
│ ├── PreferenceStore.cs
│ ├── PreferenceStoreConfiguration.cs
│ ├── PreferenceTypeConverter.cs
│ ├── RegistryPreferenceStore.cs
│ └── Xamarin.Preferences.csproj
├── Xamarin.ProcessControl.Tests
│ ├── ExecTests.cs
│ ├── ProcessArguments.cs
│ └── Xamarin.ProcessControl.Tests.csproj
├── Xamarin.ProcessControl
│ ├── ConsoleRedirection.cs
│ ├── Exec.cs
│ ├── ExecFlags.cs
│ ├── ExecStatus.cs
│ ├── ProcessArguments.cs
│ └── Xamarin.ProcessControl.csproj
├── Xamarin.PropertyListDeserializer
│ ├── PropertyListDeserializer.cs
│ └── Xamarin.PropertyListDeserializer.csproj
├── Xamarin.Security.Keychain.Tests
│ ├── KeychainSecretNameTests.cs
│ ├── KeychainSecretTests.cs
│ ├── KeychainTests.cs
│ └── Xamarin.Security.Keychain.Tests.csproj
├── Xamarin.Security.Keychain
│ ├── Assert.cs
│ ├── Keychain.cs
│ ├── KeychainExceptions.cs
│ ├── KeychainSecret.cs
│ ├── KeychainSecretName.cs
│ ├── Keychains
│ │ ├── AppleKeychain.cs
│ │ ├── DPAPIKeychain.cs
│ │ ├── FileSystemKeychain.cs
│ │ ├── IKeychain.cs
│ │ ├── ManagedProtectionKeychain.cs
│ │ └── OSKeychain.cs
│ ├── Mono.Security.Cryptography
│ │ ├── Locale.cs
│ │ └── ManagedProtection.cs
│ └── Xamarin.Security.Keychain.csproj
└── Xamarin.XunitHelpers
│ ├── GB18030TestData.cs
│ ├── OSFactAttribute.cs
│ ├── OSTheoryAttribute.cs
│ └── Xamarin.XunitHelpers.csproj
└── tools
└── ILRepackPatcher
├── ILRepackPatcher.cs
└── ILRepackPatcher.csproj
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome:http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Don't use tabs for indentation.
7 | [*]
8 | indent_style = space
9 | end_of_line = lf
10 | # (Please don't specify an indent_size here; that has too many unintended consequences.)
11 |
12 | # Code files
13 | [*.{cs,csx,vb,vbx}]
14 | indent_size = 4
15 |
16 | # Xml project files
17 | [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
18 | indent_size = 2
19 |
20 | # Xml config files
21 | [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
22 | indent_size = 2
23 |
24 | # Web files
25 | [*.{json,ts,js,html}]
26 | indent_size = 2
27 |
28 | # Dotnet code style settings:
29 | [*.{cs,vb}]
30 | # Sort using and Import directives with System.* appearing first
31 | dotnet_sort_system_directives_first = true
32 | # Avoid "this." and "Me." if not necessary
33 | dotnet_style_qualification_for_field = false:suggestion
34 | dotnet_style_qualification_for_property = false:suggestion
35 | dotnet_style_qualification_for_method = false:suggestion
36 | dotnet_style_qualification_for_event = false:suggestion
37 |
38 | # Use language keywords instead of framework type names for type references
39 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
40 | dotnet_style_predefined_type_for_member_access = true:suggestion
41 |
42 | # Suggest more modern language features when available
43 | dotnet_style_object_initializer = true:suggestion
44 | dotnet_style_collection_initializer = true:suggestion
45 | dotnet_style_coalesce_expression = true:suggestion
46 | dotnet_style_null_propagation = true:suggestion
47 | dotnet_style_explicit_tuple_names = false:suggestion
48 |
49 | # CSharp code style settings:
50 | [*.cs]
51 | # Prefer "var" everywhere
52 | csharp_style_var_for_built_in_types = true:suggestion
53 | csharp_style_var_when_type_is_apparent = true:suggestion
54 | csharp_style_var_elsewhere = true:suggestion
55 |
56 | # Prefer method-like constructs to have a block body
57 | csharp_style_expression_bodied_methods = true:none
58 | csharp_style_expression_bodied_constructors = false:none
59 | csharp_style_expression_bodied_operators = false:none
60 |
61 | # Prefer property-like constructs to have an expression-body
62 | csharp_style_expression_bodied_properties = true:none
63 | csharp_style_expression_bodied_indexers = true:none
64 | csharp_style_expression_bodied_accessors = true:none
65 |
66 | # Suggest more modern language features when available
67 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
68 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
69 | csharp_style_inlined_variable_declaration = true:suggestion
70 | csharp_style_throw_expression = true:suggestion
71 | csharp_style_conditional_delegate_call = true:suggestion
72 |
73 | # Newline settings
74 | csharp_new_line_before_open_brace = methods,types
75 | csharp_new_line_before_else = false
76 | csharp_new_line_before_catch = false
77 | csharp_new_line_before_finally = false
78 | csharp_new_line_before_members_in_object_initializers = true
79 | csharp_new_line_before_members_in_anonymous_types = true
80 |
81 | # Indentation preferences
82 | csharp_indent_block_contents = true
83 | csharp_indent_braces = false
84 | csharp_indent_case_contents = true
85 | csharp_indent_switch_labels = false
86 | csharp_indent_labels = flush_left
87 |
88 | # Space preferences
89 | csharp_space_after_cast = false
90 | csharp_space_after_colon_in_inheritance_clause = true
91 | csharp_space_after_comma = true
92 | csharp_space_after_dot = false
93 | csharp_space_after_keywords_in_control_flow_statements = true
94 | csharp_space_after_semicolon_in_for_statement = true
95 | csharp_space_around_binary_operators = before_and_after
96 | csharp_space_around_declaration_statements = do_not_ignore
97 | csharp_space_before_colon_in_inheritance_clause = true
98 | csharp_space_before_comma = false
99 | csharp_space_before_dot = false
100 | csharp_space_before_open_square_brackets = true
101 | csharp_space_before_semicolon_in_for_statement = false
102 | csharp_space_between_empty_square_brackets = false
103 | csharp_space_between_method_call_empty_parameter_list_parentheses = false
104 | csharp_space_between_method_call_name_and_opening_parenthesis = true
105 | csharp_space_between_method_call_parameter_list_parentheses = false
106 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
107 | csharp_space_between_method_declaration_name_and_open_parenthesis = true
108 | csharp_space_between_method_declaration_parameter_list_parentheses = false
109 | csharp_space_between_square_brackets = false
110 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ master ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v2
16 | with:
17 | fetch-depth: 0
18 |
19 | - name: Setup .NET
20 | uses: actions/setup-dotnet@v1
21 |
22 | - name: Restore dependencies
23 | run: dotnet restore /v:n /bl:_artifacts/restore.binlog
24 |
25 | - name: Build
26 | run: dotnet build --no-restore /v:n /bl:_artifacts/build.binlog
27 |
28 | - name: Test
29 | run: for proj in `find . -name *.Tests.csproj`; do dotnet test $proj --no-restore --no-build; done
30 |
31 | - name: Pack
32 | run: dotnet pack --no-restore --no-build /v:n /bl:_artifacts/pack.binlog
33 |
34 | - uses: actions/upload-artifact@v2.2.4
35 | with:
36 | path: _artifacts/**/*
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | _artifacts/
4 |
5 | /.vscode/launch.json
6 | /.vscode/tasks.json
7 | /.vs/
8 |
--------------------------------------------------------------------------------
/.vsts-ci-steps.yml:
--------------------------------------------------------------------------------
1 | steps:
2 | - task: DotNetCoreInstaller@0
3 | inputs:
4 | version: 2.1.500
5 | displayName: Install .NET Core
6 |
7 | # This script runs both via bash (macOS/Linux) and cmd (Windows).
8 | # Keep it both valid bash and batch or break it out conditionally.
9 | - script: |
10 | echo System Environment
11 | set
12 | echo .NET Core Info
13 | dotnet --info
14 | displayName: Dump Environment
15 |
16 | - script: |
17 | dotnet msbuild /noautoresponse /t:Restore /v:n /bl:_artifacts/restore.binlog mirepoix.proj
18 | displayName: Restore
19 |
20 | - script: |
21 | dotnet msbuild /noautoresponse /t:Build /v:n /bl:_artifacts/build.binlog mirepoix.proj
22 | displayName: Build
23 |
24 | - task: DotNetCoreCLI@2
25 | inputs:
26 | command: test
27 | projects: '**/*.Tests.csproj'
28 | arguments: '--no-restore --no-build'
29 | displayName: Run xUnit Tests
30 | continueOnError: true
--------------------------------------------------------------------------------
/.vsts-ci.yml:
--------------------------------------------------------------------------------
1 | resources:
2 | repositories:
3 | - repository: mirepoix
4 | type: github
5 | name: xamarin/mirepoix
6 | ref: refs/heads/master
7 | endpoint: GitHub-XamarinInteractive
8 |
9 | trigger:
10 | - master
11 |
12 | pr:
13 | - master
14 |
15 | jobs:
16 | - job: macOS
17 | pool:
18 | vmImage: 'macOS-10.14'
19 | steps:
20 | - template: .vsts-ci-steps.yml
21 |
22 | - job: Linux
23 | pool:
24 | vmImage: 'ubuntu-16.04'
25 | steps:
26 | - template: .vsts-ci-steps.yml
27 |
28 | - job: Windows
29 | pool:
30 | vmImage: 'vs2017-win2016'
31 | steps:
32 | - template: .vsts-ci-steps.yml
33 |
34 | - script: |
35 | dotnet msbuild /noautoresponse /t:Pack /p:BuildProjectReferences=false /p:NoBuild=true /v:m /bl:_artifacts/pack.binlog mirepoix.proj
36 | displayName: Pack Libraries
37 |
38 | - task: PublishBuildArtifacts@1
39 | inputs:
40 | ArtifactName: Artifacts
41 | PathtoPublish: _artifacts
42 | displayName: Publish Artifacts
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation. All rights reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Mirepoix
2 |
3 | [](https://devdiv.visualstudio.com/DevDiv/_build/latest?definitionId=9683)
4 |
5 | > A mirepoix (/mɪərˈpwɑː/ meer-PWAH) is a flavor base made from diced
6 | vegetables that are cooked, usually with butter or oil or other fat,
7 | for a long time on a low heat without color or browning.
8 |
9 | This project contains a handful of useful utility libraries for constructing
10 | applications. All libraries target .NET Standard 2.0, but may have
11 | platform-specific components.
12 |
13 | Most of the functionality in this project has been derived from various
14 | utility APIs within other projects within Xamarin, particularly
15 | [Xamarin Workbooks](https://github.com/Microsoft/workbooks).
16 |
17 | Please [browse the full documentation][docs] for more information on
18 | consuming Mirepoix libraries.
19 |
20 | ## Use
21 |
22 | _Mirepoix is currently distributed on [MyGet][myget] while it is still
23 | establishing itself. It will move to nuget.org eventually._
24 |
25 | Add the feed to your project's `NuGet.config` to reference packages.
26 |
27 | ### NuGet.config
28 |
29 | ```xml
30 |
31 |
32 |
35 |
36 |
37 | ```
38 |
39 | ## Hack
40 |
41 | [.NET Core 2.1][dotnetcore] is used to build, test, and package Mirepoix.
42 |
43 | ### Build all Projects
44 |
45 | ```
46 | dotnet build
47 | ```
48 |
49 | ### Package all NuGets
50 |
51 | ```
52 | dotnet pack
53 | ```
54 |
55 | ### Write
56 |
57 | * Open the root of the repository as a workspace in VS Code (`code .`) and
58 | ensure OmniSharp is using `mirepoix.sln`
59 |
60 | * Or open `mirepoix.sln` in Visual Studio or Visual Studio for Mac.
61 |
62 | ### Test
63 |
64 | It's best to simply run `dotnet xunit` at the root of the `src/*.Tests/`
65 | directory to run scoped tests for the library of interest.
66 |
67 | Unfortunately running `dotnet test` at the root of the repository fails
68 | on both Windows and macOS locally, even though VSTS is happy to do it.
69 |
70 | ### CI
71 |
72 | VSTS is used to produce official builds. See `.vsts-ci.yml`.
73 |
74 | # Contributing
75 |
76 | This project welcomes contributions and suggestions. Most contributions
77 | require you to agree to a Contributor License Agreement (CLA) declaring that
78 | you have the right to, and actually do, grant us the rights to use your
79 | contribution. For details, visit https://cla.microsoft.com.
80 |
81 | When you submit a pull request, a CLA-bot will automatically determine
82 | whether you need to provide a CLA and decorate the PR appropriately (e.g.,
83 | label, comment). Simply follow the instructions provided by the bot. You will
84 | only need to do this once across all repos using our CLA.
85 |
86 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
87 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
88 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any
89 | additional questions or comments.
90 |
91 | [docs]: https://xamarin.github.io/mirepoix
92 | [myget]: https://www.myget.org/feed/index/mirepoix
93 | [dotnetcore]: https://www.microsoft.com/net/download
--------------------------------------------------------------------------------
/docfx/api/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # temp file #
3 | ###############
4 | *.yml
5 | .manifest
6 |
--------------------------------------------------------------------------------
/docfx/api/index.md:
--------------------------------------------------------------------------------
1 | # PLACEHOLDER
2 | TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*!
3 |
--------------------------------------------------------------------------------
/docfx/articles/toc.yml:
--------------------------------------------------------------------------------
1 | - name: MSBuild Traversal Projects with Solution Generation
2 | href: traversal-projects-with-solutions.md
3 |
--------------------------------------------------------------------------------
/docfx/docfx.json:
--------------------------------------------------------------------------------
1 | {
2 | "metadata": [
3 | {
4 | "src": [
5 | {
6 | "src": "../src",
7 | "files": [
8 | "Xamarin.Preferences/Xamarin.Preferences.csproj",
9 | "Xamarin.ProcessControl/Xamarin.ProcessControl.csproj",
10 | "Xamarin.Helpers/Xamarin.Helpers.csproj",
11 | "Xamarin.NativeHelpers/Xamarin.NativeHelpers.csproj",
12 | "Xamarin.Downloader/Xamarin.Downloader.csproj",
13 | "Xamarin.MSBuild.Sdk/Xamarin.MSBuild.Sdk.csproj",
14 | "Xamarin.XunitHelpers/Xamarin.XunitHelpers.csproj",
15 | "Xamarin.Security.Keychain/Xamarin.Security.Keychain.csproj",
16 | "Xamarin.BuildConsolidator/Xamarin.BuildConsolidator.csproj"
17 | ],
18 | "exclude": []
19 | }
20 | ],
21 | "dest": "api",
22 | "filter": "filterConfig.yml",
23 | "disableGitFeatures": false,
24 | "disableDefaultFilter": false
25 | }
26 | ],
27 | "build": {
28 | "content": [
29 | {
30 | "files": [
31 | "api/**.yml",
32 | "api/index.md"
33 | ]
34 | },
35 | {
36 | "files": [
37 | "articles/**.md",
38 | "articles/**/toc.yml",
39 | "toc.yml",
40 | "*.md"
41 | ]
42 | }
43 | ],
44 | "resource": [
45 | {
46 | "files": [
47 | "images/**"
48 | ]
49 | }
50 | ],
51 | "overwrite": [
52 | {
53 | "files": [
54 | "apidoc/**.md"
55 | ],
56 | "exclude": [
57 | "obj/**"
58 | ]
59 | }
60 | ],
61 | "dest": "../docs",
62 | "globalMetadataFiles": [],
63 | "fileMetadataFiles": [],
64 | "template": [
65 | "default"
66 | ],
67 | "postProcessors": [],
68 | "markdownEngineName": "markdig",
69 | "noLangKeyword": false,
70 | "keepFileLink": false,
71 | "cleanupCacheHistory": false,
72 | "disableGitFeatures": false
73 | }
74 | }
--------------------------------------------------------------------------------
/docfx/filterConfig.yml:
--------------------------------------------------------------------------------
1 | apiRules:
2 | - exclude:
3 | uidRegex: ^System\.Object$
4 | type: Type
5 | - exclude:
6 | uidRegex: ^.*\.Tests$
7 | type: Namespace
--------------------------------------------------------------------------------
/docfx/index.md:
--------------------------------------------------------------------------------
1 | # This is the **HOMEPAGE**.
2 | Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
3 | ## Quick Start Notes:
4 | 1. Add images to the *images* folder if the file is referencing an image.
5 |
--------------------------------------------------------------------------------
/docfx/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Articles
2 | href: articles/
3 | - name: API Documentation
4 | href: api/
5 | homepage: api/index.md
6 |
--------------------------------------------------------------------------------
/docs/articles/toc.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/mirepoix/265820cc5786c571bb47cf594c55ce1da31ddc71/docs/favicon.ico
--------------------------------------------------------------------------------
/docs/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/mirepoix/265820cc5786c571bb47cf594c55ce1da31ddc71/docs/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/docs/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/mirepoix/265820cc5786c571bb47cf594c55ce1da31ddc71/docs/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/docs/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/mirepoix/265820cc5786c571bb47cf594c55ce1da31ddc71/docs/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/docs/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/mirepoix/265820cc5786c571bb47cf594c55ce1da31ddc71/docs/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | This is the HOMEPAGE.
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
50 |
51 |
58 |
59 |
60 |
61 |
62 |
63 | This is the HOMEPAGE.
64 |
65 | Refer to Markdown for how to write markdown files.
66 | Quick Start Notes:
67 |
68 | - Add images to the images folder if the file is referencing an image.
69 |
70 |
71 |
72 |
73 |
87 |
88 |
89 |
90 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/docs/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
4 |
26 |
--------------------------------------------------------------------------------
/docs/search-stopwords.json:
--------------------------------------------------------------------------------
1 | [
2 | "a",
3 | "able",
4 | "about",
5 | "across",
6 | "after",
7 | "all",
8 | "almost",
9 | "also",
10 | "am",
11 | "among",
12 | "an",
13 | "and",
14 | "any",
15 | "are",
16 | "as",
17 | "at",
18 | "be",
19 | "because",
20 | "been",
21 | "but",
22 | "by",
23 | "can",
24 | "cannot",
25 | "could",
26 | "dear",
27 | "did",
28 | "do",
29 | "does",
30 | "either",
31 | "else",
32 | "ever",
33 | "every",
34 | "for",
35 | "from",
36 | "get",
37 | "got",
38 | "had",
39 | "has",
40 | "have",
41 | "he",
42 | "her",
43 | "hers",
44 | "him",
45 | "his",
46 | "how",
47 | "however",
48 | "i",
49 | "if",
50 | "in",
51 | "into",
52 | "is",
53 | "it",
54 | "its",
55 | "just",
56 | "least",
57 | "let",
58 | "like",
59 | "likely",
60 | "may",
61 | "me",
62 | "might",
63 | "most",
64 | "must",
65 | "my",
66 | "neither",
67 | "no",
68 | "nor",
69 | "not",
70 | "of",
71 | "off",
72 | "often",
73 | "on",
74 | "only",
75 | "or",
76 | "other",
77 | "our",
78 | "own",
79 | "rather",
80 | "said",
81 | "say",
82 | "says",
83 | "she",
84 | "should",
85 | "since",
86 | "so",
87 | "some",
88 | "than",
89 | "that",
90 | "the",
91 | "their",
92 | "them",
93 | "then",
94 | "there",
95 | "these",
96 | "they",
97 | "this",
98 | "tis",
99 | "to",
100 | "too",
101 | "twas",
102 | "us",
103 | "wants",
104 | "was",
105 | "we",
106 | "were",
107 | "what",
108 | "when",
109 | "where",
110 | "which",
111 | "while",
112 | "who",
113 | "whom",
114 | "why",
115 | "will",
116 | "with",
117 | "would",
118 | "yet",
119 | "you",
120 | "your"
121 | ]
122 |
--------------------------------------------------------------------------------
/docs/styles/main.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/mirepoix/265820cc5786c571bb47cf594c55ce1da31ddc71/docs/styles/main.css
--------------------------------------------------------------------------------
/docs/styles/main.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
2 |
--------------------------------------------------------------------------------
/docs/styles/search-worker.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | importScripts('lunr.min.js');
3 |
4 | var lunrIndex;
5 |
6 | var stopWords = null;
7 | var searchData = {};
8 |
9 | lunr.tokenizer.seperator = /[\s\-\.]+/;
10 |
11 | var stopWordsRequest = new XMLHttpRequest();
12 | stopWordsRequest.open('GET', '../search-stopwords.json');
13 | stopWordsRequest.onload = function () {
14 | if (this.status != 200) {
15 | return;
16 | }
17 | stopWords = JSON.parse(this.responseText);
18 | buildIndex();
19 | }
20 | stopWordsRequest.send();
21 |
22 | var searchDataRequest = new XMLHttpRequest();
23 |
24 | searchDataRequest.open('GET', '../index.json');
25 | searchDataRequest.onload = function () {
26 | if (this.status != 200) {
27 | return;
28 | }
29 | searchData = JSON.parse(this.responseText);
30 |
31 | buildIndex();
32 |
33 | postMessage({ e: 'index-ready' });
34 | }
35 | searchDataRequest.send();
36 |
37 | onmessage = function (oEvent) {
38 | var q = oEvent.data.q;
39 | var hits = lunrIndex.search(q);
40 | var results = [];
41 | hits.forEach(function (hit) {
42 | var item = searchData[hit.ref];
43 | results.push({ 'href': item.href, 'title': item.title, 'keywords': item.keywords });
44 | });
45 | postMessage({ e: 'query-ready', q: q, d: results });
46 | }
47 |
48 | function buildIndex() {
49 | if (stopWords !== null && !isEmpty(searchData)) {
50 | lunrIndex = lunr(function () {
51 | this.pipeline.remove(lunr.stopWordFilter);
52 | this.ref('href');
53 | this.field('title', { boost: 50 });
54 | this.field('keywords', { boost: 20 });
55 |
56 | for (var prop in searchData) {
57 | if (searchData.hasOwnProperty(prop)) {
58 | this.add(searchData[prop]);
59 | }
60 | }
61 |
62 | var docfxStopWordFilter = lunr.generateStopWordFilter(stopWords);
63 | lunr.Pipeline.registerFunction(docfxStopWordFilter, 'docfxStopWordFilter');
64 | this.pipeline.add(docfxStopWordFilter);
65 | this.searchPipeline.add(docfxStopWordFilter);
66 | });
67 | }
68 | }
69 |
70 | function isEmpty(obj) {
71 | if(!obj) return true;
72 |
73 | for (var prop in obj) {
74 | if (obj.hasOwnProperty(prop))
75 | return false;
76 | }
77 |
78 | return true;
79 | }
80 | })();
81 |
--------------------------------------------------------------------------------
/docs/toc.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "2.1.505"
4 | },
5 | "msbuild-sdks": {
6 | "Microsoft.Build.Traversal": "1.0.45"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/mirepoix.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | $([MSBuild]::NormalizePath('docfx\docfx.json'))
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/msbuild.rsp:
--------------------------------------------------------------------------------
1 | mirepoix.proj /v:m
2 |
--------------------------------------------------------------------------------
/src/CI.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | true
5 |
6 | false
7 | true
8 |
9 |
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | latest
7 | true
8 | true
9 | true
10 |
11 |
12 |
13 | Microsoft
14 | © Microsoft Corporation. All rights reserved.
15 | https://github.com/xamarin/mirepoix
16 | https://xamarin.github.io/mirepoix
17 | MIT
18 | https://www.xamarin.com/content/images/nuget/xamarin.png
19 | $([MSBuild]::NormalizePath($(MSBuildThisFileDirectory)..\_artifacts\))
20 | true
21 |
22 |
23 |
24 | false
25 | true
26 |
27 |
28 |
29 | netcoreapp2.1
30 | false
31 | xUnit1026
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | all
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/Version.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | true
5 | high
6 |
7 |
8 |
9 | SetVersions;$(GenerateNuspecDependsOn)
10 | SetVersions;$(GetPackageVersionDependsOn)
11 |
12 |
--------------------------------------------------------------------------------
/src/Version.targets:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | $(SYSTEM_PULLREQUEST_TARGETBRANCH)
10 | $(BUILD_SOURCEBRANCHNAME)
11 | $(APPVEYOR_REPO_BRANCH)
12 |
13 |
14 |
15 |
18 |
19 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 | @(VersionMetadata -> '%(Identity)', '-')
32 | +$(VersionMetadataLabel)
33 | $(GitBaseVersionMajor).$(GitBaseVersionMinor).$(GitBaseVersionPatch)$(GitSemVerDashLabel)
34 | $(PackageVersion)$(VersionMetadataPlusLabel)
35 |
36 |
37 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator.Tests/FakeTest.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 |
3 | public class FakeTest
4 | {
5 | [Fact]
6 | public void Nop ()
7 | {
8 | }
9 | }
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator.Tests/Xamarin.BuildConsolidator.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Xamarin.Mirepoix
4 | $(MSBuildThisFileDirectory)..\Xamarin.BuildConsolidator\
5 | $(XamarinBuildConsolidatorProjectPath)\bin\Debug\netstandard2.0\Xamarin.BuildConsolidator.dll
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | A consolidated package containing @(PackageIdsToConsolidate -> '%(Identity)', ', ') in a single $(PackageId).dll assembly.
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator/FrameworkReferenceAssemblyComparer.cs:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // Author:
4 | // Aaron Bockover
5 | //
6 | // Copyright (c) Microsoft Corporation. All rights reserved.
7 | // Licensed under the MIT License.
8 |
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 |
13 | using NuGet.Packaging;
14 |
15 | namespace Xamarin.BuildConsolidator
16 | {
17 | sealed class FrameworkAssemblyReferenceComparer : IEqualityComparer
18 | {
19 | public bool Equals (FrameworkAssemblyReference x, FrameworkAssemblyReference y)
20 | {
21 | if (!string.Equals (x.AssemblyName, y.AssemblyName, StringComparison.OrdinalIgnoreCase))
22 | return false;
23 |
24 | return x.SupportedFrameworks.SequenceEqual (y.SupportedFrameworks);
25 | }
26 |
27 | public int GetHashCode (FrameworkAssemblyReference obj)
28 | => 0;
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator/ILRepackMSBuildLogger.cs:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // Author:
4 | // Aaron Bockover
5 | //
6 | // Copyright (c) Microsoft Corporation. All rights reserved.
7 | // Licensed under the MIT License.
8 |
9 | using System;
10 |
11 | using Microsoft.Build.Framework;
12 | using Microsoft.Build.Utilities;
13 |
14 | namespace Xamarin.BuildConsolidator
15 | {
16 | sealed class ILRepackMSBuildLogger : ILRepacking.ILogger
17 | {
18 | readonly TaskLoggingHelper log;
19 |
20 | public ILRepackMSBuildLogger (TaskLoggingHelper log)
21 | => this.log = log;
22 |
23 | bool ILRepacking.ILogger.ShouldLogVerbose { get; set; }
24 |
25 | void ILRepacking.ILogger.DuplicateIgnored (string ignoredType, object ignoredObject)
26 | => log.LogMessage (
27 | MessageImportance.Low,
28 | "Ignoring duplicate {0} {1}",
29 | ignoredType,
30 | ignoredObject);
31 |
32 | void ILRepacking.ILogger.Log (object str)
33 | => log.LogMessage (MessageImportance.Normal, str.ToString ());
34 |
35 | void ILRepacking.ILogger.Error (string msg)
36 | => log.LogError (msg);
37 |
38 | void ILRepacking.ILogger.Warn (string msg)
39 | {
40 | if (!msg.StartsWith ("Did not write source server data to output assembly.", StringComparison.OrdinalIgnoreCase))
41 | log.LogWarning (msg);
42 | }
43 |
44 | void ILRepacking.ILogger.Info (string msg)
45 | => log.LogMessage (MessageImportance.Normal, msg);
46 |
47 | void ILRepacking.ILogger.Verbose (string msg)
48 | => log.LogMessage (MessageImportance.Low, msg);
49 | }
50 | }
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator/NuGetLocalRepoHelper.cs:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // Author:
4 | // Aaron Bockover
5 | //
6 | // Copyright (c) Microsoft Corporation. All rights reserved.
7 | // Licensed under the MIT License.
8 |
9 | using System;
10 | using System.Collections.Generic;
11 | using System.IO;
12 | using System.Linq;
13 |
14 | using NuGet.Common;
15 | using NuGet.Frameworks;
16 | using NuGet.Repositories;
17 | using NuGet.Versioning;
18 |
19 | namespace Xamarin.BuildConsolidator
20 | {
21 | static class NuGetLocalRepoHelper
22 | {
23 | static readonly NuGetv3LocalRepository repo = new NuGetv3LocalRepository (
24 | Path.Combine (
25 | NuGetEnvironment.GetFolderPath (NuGetFolderPath.NuGetHome),
26 | "packages"));
27 |
28 | public static LocalPackageInfo GetPackage (
29 | string id,
30 | VersionRange versionRange)
31 | {
32 | var packageCandidates = repo
33 | .FindPackagesById (id)
34 | .ToList ();
35 |
36 | if (packageCandidates.Count == 0)
37 | return null;
38 |
39 | var bestVersion = versionRange.FindBestMatch (
40 | packageCandidates.Select (p => p.Version));
41 |
42 | return packageCandidates.FirstOrDefault (
43 | p => p.Version == bestVersion);
44 | }
45 |
46 | public static string GetPackageAssemblySearchPath (
47 | string id,
48 | VersionRange versionRange,
49 | NuGetFramework framework)
50 | => GetPackageAssemblySearchPath (
51 | GetPackage (id, versionRange),
52 | framework);
53 |
54 | public static string GetPackageAssemblySearchPath (
55 | LocalPackageInfo packageInfo,
56 | NuGetFramework framework)
57 | {
58 | if (packageInfo == null)
59 | return null;
60 |
61 | if (framework == null)
62 | throw new ArgumentNullException (nameof (framework));
63 |
64 | var possibleFrameworks = packageInfo.Files
65 | .Select (path => path.Split (new [] { '/', '\\' }))
66 | .Where (parts => string.Equals (parts [0], "lib", StringComparison.OrdinalIgnoreCase))
67 | .Select (parts => NuGetFramework.ParseFolder (parts [1].ToLowerInvariant ()))
68 | .Distinct ();
69 |
70 | var bestFramework = new FrameworkReducer ()
71 | .GetNearest (framework, possibleFrameworks);
72 |
73 | return Path.Combine (
74 | packageInfo.ExpandedPath,
75 | "lib",
76 | bestFramework.GetShortFolderName ());
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator/Xamarin.BuildConsolidator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | Xamarin.BuildConsolidator.Unpacked
5 | Xamarin.BuildConsolidator
6 | false
7 | $(TargetsForTfmSpecificContentInPackage);GetPackageBuildFiles
8 |
9 |
10 |
11 |
12 |
13 | all
14 |
15 |
16 |
17 | all
18 |
19 |
20 |
21 |
22 |
23 | $(ILRepack)
24 |
25 |
26 |
27 |
28 |
29 | all
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator/Xamarin.BuildConsolidator.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
26 |
27 |
33 |
34 |
39 |
40 |
45 |
46 |
47 |
48 |
49 |
50 | build
51 |
52 |
53 | build
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator/build/Xamarin.BuildConsolidator.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | $(PackDependsOn);PackConsolidated
5 | $(GetPackageVersionDependsOn);GetPackagesToConsolidate
6 |
7 |
--------------------------------------------------------------------------------
/src/Xamarin.BuildConsolidator/build/Xamarin.BuildConsolidator.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 | $(MSBuildThisFileDirectory)Xamarin.BuildConsolidator.dll
4 |
5 |
6 |
9 |
10 |
13 |
14 |
17 |
37 |
38 |
--------------------------------------------------------------------------------
/src/Xamarin.Cecil.Rocks.Tests/MetadataVisitorTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using Xunit;
8 |
9 | using Mono.Cecil;
10 |
11 | namespace Xamarin.Cecil.Rocks
12 | {
13 | public class MetadataVisitorTests
14 | {
15 | static readonly AssemblyDefinition TestAssemblyDefinition = AssemblyDefinition.ReadAssembly (
16 | typeof (MetadataVisitorTests).Assembly.Location);
17 |
18 | class TestVisitAssemblyDefinition : MetadataVisitor
19 | {
20 | int invocations;
21 |
22 | public override bool VisitAssemblyDefinition (AssemblyDefinition assemblyDefinition)
23 | {
24 | Assert.Equal (TestAssemblyDefinition, assemblyDefinition);
25 | Assert.Equal (1, ++invocations);
26 | return true;
27 | }
28 | }
29 |
30 | [Fact]
31 | public void VisitAssemblyDefinition ()
32 | => TestAssemblyDefinition.AcceptVisitor (new TestVisitAssemblyDefinition ());
33 |
34 | class TestVisitTypeDefinition : MetadataVisitor
35 | {
36 | class C { }
37 | class C { }
38 | class C { public class A { } }
39 | class C { public class A { } }
40 | enum E { }
41 | struct S { }
42 |
43 | public List ExpectedTypes { get; } = new List {
44 | typeof(ThisAssembly),
45 | typeof(ThisAssembly.Git),
46 | typeof(ThisAssembly.Git.BaseVersion),
47 | typeof(ThisAssembly.Git.SemVer),
48 | typeof(MetadataVisitorTests),
49 | typeof(TestVisitAssemblyDefinition),
50 | typeof(TestVisitTypeDefinition),
51 | typeof(C<>),
52 | typeof(C<,>),
53 | typeof(C<,,>),
54 | typeof(C<,,>.A),
55 | typeof(C<,,,>),
56 | typeof(C<,,,>.A<>),
57 | typeof(E),
58 | typeof(S)
59 | };
60 |
61 | public override bool VisitTypeDefinition (TypeDefinition typeDefinition)
62 | {
63 | var fullName = typeDefinition.FullName.Replace ('/', '+');
64 | switch (fullName) {
65 | case "":
66 | case "AutoGeneratedProgram":
67 | return true;
68 | }
69 |
70 | for (int i = ExpectedTypes.Count - 1; i >= 0; i--) {
71 | if (ExpectedTypes [i].FullName == fullName) {
72 | ExpectedTypes.RemoveAt (i);
73 | return true;
74 | }
75 | }
76 |
77 | throw new Exception ($"{typeDefinition} is unexpected");
78 | }
79 | }
80 |
81 | [Fact]
82 | public void VisitTypeDefinition ()
83 | {
84 | var visitor = new TestVisitTypeDefinition ();
85 | TestAssemblyDefinition.AcceptVisitor (visitor);
86 | Assert.Empty (visitor.ExpectedTypes);
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/src/Xamarin.Cecil.Rocks.Tests/Xamarin.Cecil.Rocks.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Xamarin.Cecil.Rocks/AssemblyCollection.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 |
8 | using Mono.Cecil;
9 |
10 | namespace Xamarin.Cecil.Rocks
11 | {
12 | public class AssemblyCollection
13 | {
14 | readonly HashSet searchDirectories = new HashSet ();
15 | readonly List assemblyFileNames = new List ();
16 |
17 | public ReaderParameters ReaderParameters { get; }
18 | public BaseAssemblyResolver AssemblyResolver { get; }
19 |
20 | public AssemblyCollection (ReadingMode readingMode = ReadingMode.Immediate) : this (
21 | new ReaderParameters (readingMode),
22 | new DefaultAssemblyResolver ())
23 | {
24 | }
25 |
26 | public AssemblyCollection (
27 | ReaderParameters readerParameters,
28 | BaseAssemblyResolver assemblyResolver)
29 | {
30 | ReaderParameters = readerParameters
31 | ?? throw new ArgumentNullException (nameof (readerParameters));
32 |
33 | ReaderParameters.AssemblyResolver = assemblyResolver;
34 | ReaderParameters.MetadataResolver = new MetadataResolver (assemblyResolver);
35 |
36 | AssemblyResolver = assemblyResolver
37 | ?? throw new ArgumentNullException (nameof (assemblyResolver));
38 | }
39 |
40 | public AssemblyCollection AddAssembly (string assemblyFileName)
41 | {
42 | assemblyFileName = Path.GetFullPath (assemblyFileName);
43 |
44 | var searchDirectory = Path.GetDirectoryName (assemblyFileName);
45 | if (searchDirectories.Add (searchDirectory))
46 | AssemblyResolver.AddSearchDirectory (searchDirectory);
47 |
48 | if (!assemblyFileNames.Contains (assemblyFileName))
49 | assemblyFileNames.Add (assemblyFileName);
50 |
51 | return this;
52 | }
53 |
54 | public AssemblyCollection AddAssemblies (IEnumerable assemblyFileNames)
55 | {
56 | foreach (var assemblyFileName in assemblyFileNames ?? Array.Empty ())
57 | AddAssembly (assemblyFileName);
58 |
59 | return this;
60 | }
61 |
62 | public IEnumerable Load ()
63 | {
64 | foreach (var assemblyFileName in assemblyFileNames)
65 | yield return AssemblyDefinition.ReadAssembly (
66 | assemblyFileName,
67 | ReaderParameters);
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/src/Xamarin.Cecil.Rocks/MetadataVisitor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using Mono.Cecil;
5 | using Mono.Cecil.Cil;
6 |
7 | namespace Xamarin.Cecil.Rocks
8 | {
9 | public abstract class MetadataVisitor : MetadataVisitor
10 | {
11 | public override bool ShouldTraverseInto (bool visitResult)
12 | => visitResult;
13 |
14 | protected override bool VisitDefault (object any)
15 | => true;
16 | }
17 |
18 | public abstract class MetadataVisitor
19 | {
20 | public virtual bool ShouldTraverseInto (TResult visitResult)
21 | => true;
22 |
23 | protected virtual TResult VisitDefault (object any)
24 | => default;
25 |
26 | public virtual TResult VisitAssemblyDefinition (
27 | AssemblyDefinition assemblyDefinition)
28 | => VisitDefault (assemblyDefinition);
29 |
30 | public virtual TResult VisitModuleReference (
31 | ModuleReference moduleReference)
32 | => VisitDefault (moduleReference);
33 |
34 | public virtual TResult VisitModuleDefinition (
35 | ModuleDefinition moduleDefinition)
36 | => VisitDefault (moduleDefinition);
37 |
38 | public virtual TResult VisitTypeReference (
39 | TypeReference typeReference)
40 | => VisitDefault (typeReference);
41 |
42 | public virtual TResult VisitTypeDefinition (
43 | TypeDefinition typeDefinition)
44 | => VisitDefault (typeDefinition);
45 |
46 | public virtual TResult VisitInterfaceImplementation (
47 | InterfaceImplementation interfaceImplementation)
48 | => VisitDefault (interfaceImplementation);
49 |
50 | public virtual TResult VisitFieldReference (
51 | FieldReference fieldReference)
52 | => VisitDefault (fieldReference);
53 |
54 | public virtual TResult VisitFieldDefinition (
55 | FieldDefinition fieldDefinition)
56 | => VisitDefault (fieldDefinition);
57 |
58 | public virtual TResult VisitParameterDefinition (
59 | ParameterDefinition parameterDefinition)
60 | => VisitDefault (parameterDefinition);
61 |
62 | public virtual TResult VisitMethodReference (
63 | MethodReference methodReference)
64 | => VisitDefault (methodReference);
65 |
66 | public virtual TResult VisitMethodDefinition (
67 | MethodDefinition methodDefinition)
68 | => VisitDefault (methodDefinition);
69 |
70 | public virtual TResult VisitMethodBody (
71 | MethodBody methodBody)
72 | => VisitDefault (methodBody);
73 |
74 | public virtual TResult VisitInstruction (
75 | Instruction instruction)
76 | => VisitDefault (instruction);
77 |
78 | public virtual TResult VisitPropertyReference (
79 | PropertyReference propertyReference)
80 | => VisitDefault (propertyReference);
81 |
82 | public virtual TResult VisitPropertyDefinition (
83 | PropertyDefinition propertyDefinition)
84 | => VisitDefault (propertyDefinition);
85 |
86 | public virtual TResult VisitEventReference (
87 | EventReference eventReference)
88 | => VisitDefault (eventReference);
89 |
90 | public virtual TResult VisitEventDefinition (
91 | EventDefinition eventDefinition)
92 | => VisitDefault (eventDefinition);
93 |
94 | public virtual TResult VisitGenericParameter (
95 | GenericParameter genericParameter)
96 | => VisitDefault (genericParameter);
97 |
98 | public virtual TResult VisitCustomAttribute (
99 | CustomAttribute customAttribute)
100 | => VisitDefault (customAttribute);
101 |
102 | public virtual TResult VisitCustomAttributeNamedArgument (
103 | CustomAttributeNamedArgument customAttributeNamedArgument)
104 | => VisitDefault (customAttributeNamedArgument);
105 |
106 | public virtual TResult VisitCustomAttributeArgument (
107 | CustomAttributeArgument customAttributeArgument)
108 | => VisitDefault (customAttributeArgument);
109 | }
110 | }
--------------------------------------------------------------------------------
/src/Xamarin.Cecil.Rocks/Xamarin.Cecil.Rocks.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/Xamarin.Downloader.Tests/DownloadClientTests.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Author:
3 | // Aaron Bockover
4 | //
5 | // Copyright (c) Microsoft Corporation. All rights reserved.
6 | // Licensed under the MIT License.
7 |
8 | using System;
9 | using System.IO;
10 | using System.Net;
11 | using System.Net.Http;
12 | using System.Threading;
13 | using System.Threading.Tasks;
14 |
15 | using Xunit;
16 |
17 | using Xamarin.Downloader;
18 |
19 | namespace Xamarin.Downloader.Tests
20 | {
21 | public class DownloadClientTests
22 | {
23 | sealed class TestDownloadServer
24 | {
25 | readonly HttpListener httpListener;
26 |
27 | public string BaseUri { get; } = "http://localhost:8282/";
28 |
29 | public TestDownloadServer ()
30 | {
31 | var startWait = new ManualResetEvent (false);
32 |
33 | httpListener = new HttpListener ();
34 | httpListener.Prefixes.Add (BaseUri);
35 | httpListener.Start ();
36 |
37 | ThreadPool.QueueUserWorkItem (async o => {
38 | startWait.Set ();
39 |
40 | var buffer = new byte [512 * 1024 * 1024];
41 | new Random ().NextBytes (buffer);
42 |
43 | try {
44 | while (true) {
45 | var context = await httpListener.GetContextAsync ();
46 | context.Response.StatusCode = 200;
47 | context.Response.ContentLength64 = buffer.Length;
48 | await context.Response.OutputStream.WriteAsync (buffer, 0, buffer.Length);
49 | await context.Response.OutputStream.FlushAsync ();
50 | context.Response.OutputStream.Close ();
51 | context.Response.Close ();
52 | }
53 | } catch {
54 | return;
55 | }
56 | });
57 |
58 | startWait.WaitOne ();
59 | }
60 | }
61 |
62 | sealed class TestDownloadClientDelegate : DownloadClientDelegate
63 | {
64 | }
65 |
66 | readonly DownloadClient downloader = DownloadClient.Create (
67 | outputDirectory: Path.Combine (
68 | Path.GetTempPath (),
69 | "com.xamarin.mirepoix.tests",
70 | Guid.NewGuid ().ToString ()));
71 |
72 | [UnixFact (Skip = "HttpListener does not work reliably in test on Windows likely due to firewall")]
73 | public async Task DownloadBytesAsync ()
74 | {
75 | var server = new TestDownloadServer ();
76 | await downloader.DownloadAsync (server.BaseUri);
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/src/Xamarin.Downloader.Tests/Xamarin.Downloader.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/Xamarin.Downloader/Download.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Author:
3 | // Aaron Bockover
4 | //
5 | // Copyright (c) Microsoft Corporation. All rights reserved.
6 | // Licensed under the MIT License.
7 |
8 | using System;
9 | using System.Collections.Generic;
10 | using System.IO;
11 | using System.Linq;
12 |
13 | namespace Xamarin.Downloader
14 | {
15 | public sealed class Download
16 | {
17 | public string RequestUri { get; }
18 | public IReadOnlyList<(string name, string value)> RequestHeaders { get; }
19 | public string OutputDirectory { get; }
20 | public string OutputFileName { get; }
21 | public string OutputFullPath { get; }
22 | internal string OutputIntermediateFullPath { get; }
23 |
24 | Download (
25 | string requestUri,
26 | IReadOnlyList<(string name, string value)> requestHeaders,
27 | string outputDirectory,
28 | string outputFileName)
29 | {
30 | RequestUri = requestUri;
31 | RequestHeaders = requestHeaders;
32 | OutputDirectory = outputDirectory;
33 | OutputFileName = outputFileName;
34 |
35 | if (!string.IsNullOrEmpty (OutputDirectory) &&
36 | !string.IsNullOrEmpty (OutputFileName)) {
37 | OutputFullPath = Path.Combine (OutputDirectory, OutputFileName);
38 | OutputIntermediateFullPath = OutputFullPath + ".downloading";
39 | }
40 | }
41 |
42 | internal static Download Create (
43 | string requestUri,
44 | IEnumerable<(string name, string value)> requestHeaders,
45 | string outputDirectory,
46 | string outputFileName)
47 | => new Download (
48 | requestUri,
49 | requestHeaders?.ToArray () ?? Array.Empty<(string, string)> (),
50 | outputDirectory,
51 | outputFileName);
52 |
53 | internal Download WithRequestHeaders (IEnumerable<(string name, string value)> requestHeaders)
54 | => requestHeaders == RequestHeaders
55 | ? this
56 | : new Download (
57 | RequestUri,
58 | requestHeaders?.ToArray () ?? Array.Empty<(string, string)> (),
59 | OutputDirectory,
60 | OutputFileName);
61 |
62 | internal Download WithOutputDirectory (string outputDirectory)
63 | => outputDirectory == OutputDirectory
64 | ? this
65 | : new Download (
66 | RequestUri,
67 | RequestHeaders,
68 | outputDirectory,
69 | OutputFileName);
70 |
71 | internal Download WithOutputFileName (string outputFileName)
72 | => outputFileName == OutputFileName
73 | ? this
74 | : new Download (
75 | RequestUri,
76 | RequestHeaders,
77 | OutputDirectory,
78 | outputFileName);
79 | }
80 | }
--------------------------------------------------------------------------------
/src/Xamarin.Downloader/DownloadClientDelegate.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Author:
3 | // Aaron Bockover
4 | //
5 | // Copyright (c) Microsoft Corporation. All rights reserved.
6 | // Licensed under the MIT License.
7 |
8 | using System;
9 | using System.IO;
10 | using System.Linq;
11 | using System.Net.Http;
12 | using System.Threading;
13 | using System.Threading.Tasks;
14 |
15 | namespace Xamarin.Downloader
16 | {
17 | public class DownloadClientDelegate
18 | {
19 | internal static bool TryGetIntermediateFileSize (Download download, out long fileSize)
20 | {
21 | if (download.OutputIntermediateFullPath != null) {
22 | var downloadingFileInfo = new FileInfo (download.OutputIntermediateFullPath);
23 | if (downloadingFileInfo.Exists) {
24 | fileSize = downloadingFileInfo.Length;
25 | return true;
26 | }
27 | }
28 |
29 | fileSize = 0;
30 | return false;
31 | }
32 |
33 | internal protected virtual Download PrepareDownload (
34 | DownloadClient downloadClient,
35 | Download download)
36 | {
37 | download = download.WithOutputDirectory (
38 | download.OutputDirectory
39 | ?? downloadClient.OutputDirectory
40 | ?? Environment.CurrentDirectory);
41 |
42 | if (download.OutputFileName == null) {
43 | var fileName = Path.GetFileName (download.RequestUri);
44 | if (string.IsNullOrEmpty (fileName))
45 | fileName = "UnknownDownload";
46 | download = download.WithOutputFileName (fileName);
47 | }
48 |
49 | var rangeHeaders = Array.Empty<(string, string)> ();
50 | if (TryGetIntermediateFileSize (download, out var totalRead))
51 | rangeHeaders = new [] {
52 | ("Range", $"bytes={totalRead}-"),
53 | ("x-ms-range", $"bytes={totalRead}-"),
54 | ("x-ms-version", "2011-08-18")
55 | };
56 |
57 | download = download.WithRequestHeaders (downloadClient
58 | .RequestHeaders
59 | .Concat (download.RequestHeaders)
60 | .Concat (rangeHeaders));
61 |
62 | return download;
63 | }
64 |
65 | internal protected virtual void NotifyDownloadAttemptFailed (
66 | Download download,
67 | Exception exception,
68 | int attempt,
69 | int maxAttempts)
70 | {
71 | }
72 |
73 | internal protected virtual void NotifyDownloadStatus (
74 | Download download,
75 | DownloadStatus status)
76 | {
77 | }
78 |
79 | internal protected virtual Task HandleHttpResponseMessageAsync (
80 | Download download,
81 | HttpResponseMessage response,
82 | CancellationToken cancellationToken)
83 | => Task.CompletedTask;
84 | }
85 | }
--------------------------------------------------------------------------------
/src/Xamarin.Downloader/DownloadStatus.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Author:
3 | // Aaron Bockover
4 | //
5 | // Copyright (c) Microsoft Corporation. All rights reserved.
6 | // Licensed under the MIT License.
7 |
8 | using System;
9 |
10 | namespace Xamarin.Downloader
11 | {
12 | ///
13 | /// Immutable record representing the status of a download at a point in time.
14 | ///
15 | public sealed class DownloadStatus
16 | {
17 | ///
18 | /// The total number of bytes expected to be downloaded.
19 | ///
20 | public long BytesExpected { get; }
21 |
22 | ///
23 | /// The total number of bytes already downloaded.
24 | ///
25 | public long BytesDownloaded { get; }
26 |
27 | ///
28 | /// The completion percentage of the download (0-1 inclusive).
29 | ///
30 | public float Progress { get; }
31 |
32 | ///
33 | /// The current rolling average speed of the download in bytes per second.
34 | ///
35 | public int BytesPerSecond { get; }
36 |
37 | ///
38 | /// The estimated time remaining to complete the download.
39 | ///
40 | public TimeSpan EstimatedTimeRemaining { get; }
41 |
42 | ///
43 | /// The amount of time taken to perform the download so far. If
44 | /// is 1 (completed), this value is the total amount of time the download took.
45 | ///
46 | public TimeSpan TimeElapsed { get; }
47 |
48 | ///
49 | /// When the download was started.
50 | ///
51 | public DateTimeOffset StartTime { get; }
52 |
53 | internal DownloadStatus (
54 | long bytesExpected,
55 | long bytesDownloaded,
56 | float progress,
57 | int bytesPerSecond,
58 | TimeSpan estimatedTimeRemaining,
59 | DateTimeOffset startTime)
60 | {
61 | BytesExpected = bytesExpected;
62 | BytesDownloaded = bytesDownloaded;
63 | Progress = progress;
64 | BytesPerSecond = bytesPerSecond;
65 | EstimatedTimeRemaining = estimatedTimeRemaining;
66 | TimeElapsed = DateTimeOffset.UtcNow - startTime;
67 | StartTime = startTime;
68 | }
69 |
70 | internal DownloadStatus WithCompletion ()
71 | => new DownloadStatus (
72 | BytesExpected,
73 | BytesExpected,
74 | 1,
75 | 0,
76 | TimeSpan.Zero,
77 | StartTime);
78 | }
79 | }
--------------------------------------------------------------------------------
/src/Xamarin.Downloader/Xamarin.Downloader.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 |
--------------------------------------------------------------------------------
/src/Xamarin.Helpers.Tests/FileHelperTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 |
8 | using Xunit;
9 |
10 | namespace Xamarin
11 | {
12 | public sealed class FileHelperTests
13 | {
14 | readonly Random random = new Random ();
15 |
16 | [Theory]
17 | [InlineData ("", null)]
18 | [InlineData ("Hello World", null)]
19 | [InlineData ("\n", "\n")]
20 | [InlineData ("\r", "\r")]
21 | [InlineData ("\r\n", "\r\n")]
22 | [InlineData ("\n\r", "\n")]
23 | [InlineData ("Hello\nWorld", "\n")]
24 | [InlineData ("Hello\rWorld", "\r")]
25 | [InlineData ("Hello\r\nWorld", "\r\n")]
26 | [InlineData ("Hello\n\rWorld", "\n")]
27 | public void DetectFileLineEnding (string fileContents, string expectedLineEnding)
28 | {
29 | var stream = new MemoryStream ();
30 | var writer = new StreamWriter (stream);
31 | writer.Write (fileContents);
32 | writer.Flush ();
33 | stream.Position = 0;
34 | var reader = new StreamReader (stream);
35 | Assert.Equal (expectedLineEnding, FileHelpers.DetectFileLineEnding (reader));
36 | }
37 |
38 | public static IEnumerable