-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open source Retry and Hot Reload extensions
- Loading branch information
1 parent
b10bda3
commit 1a51f49
Showing
66 changed files
with
4,807 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
MICROSOFT SOFTWARE LICENSE TERMS | ||
MICROSOFT TESTING PLATFORM TOOLS | ||
|
||
These license terms are an agreement between you and Microsoft Corporation (or based on where you live, one of its affiliates). They apply to the software named above, and the software listed or available at https://aka.ms/testingplatform/extensions (collectively "Software"). The terms also apply to any Microsoft services and updates for the Software, except to the extent those have different terms. | ||
|
||
IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. | ||
|
||
1. INSTALLATION AND USE RIGHTS. | ||
|
||
(a) Individuals. If you are an individual working on your own applications, either to sell or for any other purpose, you may install and use the Software to develop and test your applications. | ||
|
||
(b) Organizations. If you are an organization, your users may install and use the Software as follows: | ||
|
||
(i) Any number of your users may use the Software to develop and test applications released under Open Source Initiative ("OSI") approved open source Software licenses. | ||
|
||
(ii) Any number of your users may use the Software to develop and test your applications as part of online or in person classroom training and education, or for performing academic research. | ||
|
||
(iii) If none of the above apply, and you are also not an Enterprise (defined below), then up to five (5) of your individual users can use the Software concurrently to develop and test your applications. | ||
|
||
(iv) If you are an Enterprise, your users may not use the Software to develop or test your applications, except for: (1) open source; and (2) education purposes, each as permitted above. | ||
|
||
An "Enterprise" is any organization and its Affiliates that collectively have either: (A) more than two-hundred fifty (250) PCs or users; or (B) one million ($1,000,000.00) U.S. dollars (or the equivalent in other currencies) in annual revenues. As used in this section, "Affiliates" means those entities that control (via majority ownership), are controlled by, or are under common control with an organization. | ||
|
||
(v) Notwithstanding Sections 1(b)(i)-(v), your users may install and use copies of the Software on your devices to develop and test applications while you have a valid paid entitlement (e.g., a paid subscription) to use at least one (1) eligible product or service listed in the supplemental licensing documentation available at https://aka.ms/vs/eligible-entitlements. Additionally: | ||
|
||
- the number of your users permitted to use the Software, and other relevant limitations, are specified in the supplemental licensing documentation referenced above; and | ||
|
||
- paid entitlements to the eligible products and services require a separate agreement with Microsoft or a Microsoft affiliate. | ||
|
||
(vi) You are responsible for your users' compliance with the terms of this agreement, as applicable. | ||
|
||
(c) Permitted Environments. You may not separate the components of the Software (except as otherwise stated in this agreement) and run those in a production environment, or on third party devices, or for any purpose other than developing and testing your applications. | ||
|
||
(d) Backup Copy. You may make one (1) backup copy of the Software, for reinstalling the Software. | ||
|
||
(e) Online Services in the Software. Some features of the Software make use of online services to provide you information about updates to the Software or extensions, or to enable you to retrieve content, collaborate with others, or otherwise supplement your development experience. As used throughout this agreement, the term "Software" includes these online service features, and by using them, you consent to the transmission of information as described in Section 3 (Data). | ||
|
||
(f) Demo Use. The use rights permitted above include using the Software to demonstrate your applications. | ||
|
||
(g) Third Party Components. The Software may include third party components with separate legal notices or governed by other agreements, as may be described in the notices file(s) accompanying the Software. | ||
|
||
(h) Use on Azure. Running the Software on Microsoft Azure may require separate online usage fees. | ||
|
||
(i) Previews. Microsoft may also make preview versions of the Software available to you. Preview versions of the Software follow semantic versioning, as that standard is described here, https://semver.org/, and preview versions may be released on multiple websites (see https://aka.ms/testingplatform/extensions). You may use any number of copies of the preview Software, components, or features consistent with the terms of these license terms. Previews are experimental and may be substantially different from the commercially released version. They may not operate correctly or work the way a final version will. Microsoft may change previews for the final, commercial version, if any. Microsoft is not obligated to provide maintenance, technical support or updates to you for previews. | ||
|
||
2. FEEDBACK. If you give feedback about the Software to Microsoft, you give to Microsoft, without charge, the right to use, share, and commercialize your feedback in any way and for any purpose. You will not give feedback that is subject to a license that requires Microsoft to license its Software or documentation to third parties because we include your feedback in them. These rights survive this agreement. | ||
|
||
3. DATA. | ||
|
||
(a) Data Collection. The Software may collect information about you and your use of the Software, and send that to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may opt-out of many of these scenarios, but not all, as described in the Software documentation. There are also some features in the Software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://aka.ms/privacy. You can learn more about data collection and its use in the Software documentation and our privacy statement. Your use of the Software operates as your consent to these practices. | ||
|
||
(b) Processing of Personal Data. To the extent Microsoft is a processor or subprocessor of personal data in connection with the software, Microsoft makes the commitments in the European Union General Data Protection Regulation Terms of the Microsoft Products and Services Data Protection Addendum to all customers effective May 25, 2018, at https://learn.microsoft.com/legal/gdpr. | ||
|
||
4. SCOPE OF LICENSE. The Software is licensed, not sold. These license terms only gives you some rights to use the Software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the Software only as expressly permitted in these license terms. In doing so, you must comply with any technical limitations in the Software that only allow you to use it in certain ways. For example, if Microsoft technically limits or disables extensibility for the Software, you may not extend the Software by, among other things, loading or injecting into the Software any non-Microsoft add-ins, macros, or packages; modifying the software registry settings; or adding features or functionality equivalent to that found in Microsoft products and services. In addition, you may not: | ||
|
||
(a) work around any technical limitations in the Software; | ||
|
||
(b) reverse engineer, decompile or disassemble the Software, or otherwise attempt to derive the source code for the Software, except and only to the extent required by third party licensing terms governing use of certain open-source components that may be included with the Software; | ||
|
||
(c) remove, minimize, block or modify any notices of Microsoft or its suppliers in the Software; | ||
|
||
(d) use the Software in any way that is against the law; | ||
|
||
(e) share, publish, rent, or lease the Software; or | ||
|
||
(f) provide the Software as a stand-alone offering or combine it with any of your applications for others to use, or transfer the Software or this agreement to any third party. | ||
|
||
5. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the Software, which include restrictions on destinations, end users and end use. For further information on export restrictions, visit (aka.ms/exporting). | ||
|
||
6. SUPPORT SERVICES. Because this Software is "as is," we may not provide support services for it. | ||
|
||
7. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the Software and support services. | ||
|
||
8. APPLICABLE LAW. If you acquired the Software in the United States, Washington law applies to interpretation of and claims for breach of this agreement, and the laws of the state where you live apply to all other claims. If you acquired the Software in any other country, its laws apply. | ||
|
||
9. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the Software. This agreement does not change those other rights if the laws of your state or country do not permit it to do so. For example, if you acquired the Software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: | ||
|
||
(a) Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. | ||
|
||
(b) Canada. If you acquired this Software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the Software will resume checking for and installing updates), or uninstalling the Software. The product documentation, if any, may also specify how to turn off updates for your specific device or Software. | ||
|
||
(c) Germany and Austria. | ||
|
||
(i) Warranty. The properly licensed Software will perform substantially as described in any Microsoft materials that accompany the Software. However, Microsoft gives no contractual guarantee in relation to the licensed Software. | ||
|
||
(ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law. | ||
|
||
Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence. | ||
|
||
10. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED "AS-IS." YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. | ||
|
||
11. LIMITATION ON AND EXCLUSION OF DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. | ||
|
||
This limitation applies to (a) anything related to the Software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages. | ||
|
||
Please note: As this Software is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French. | ||
|
||
Remarque: Ce Logiciel �tant distribu� au Qu�bec, Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en fran�ais. | ||
|
||
EXON�RATION DE GARANTIE. Le Logiciel vis� par une licence est offert � tel quel �. Toute utilisation de ce Logiciel est � votre seule risque et p�ril. Microsoft n'accorde aucune autre garantie expresse. Vous pouvez b�n�ficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. L� �u elles sont permises par le droit locale, les garanties implicites de qualit� marchande, d'ad�quation � un usage particulier et d'absence de contrefa�on sont exclues. | ||
|
||
LIMITATION DES DOMMAGES-INT�R�TS ET EXCLUSION DE RESPONSABILIT� POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement � hauteur de 5,00 $ US. Vous ne pouvez pr�tendre � aucune indemnisation pour les autres dommages, y compris les dommages sp�ciaux, indirects ou accessoires et pertes de b�n�fices. Cette limitation concerne: | ||
|
||
- tout ce qui est reli� au Logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers; et | ||
|
||
- les r�clamations au titre de violation de contrat ou de garantie, ou au titre de responsabilit� stricte, de n�gligence ou d'une autre faute dans la limite autoris�e par la loi en vigueur. | ||
Elle s'applique �galement, m�me si Microsoft connaissait ou devrait conna�tre l'�ventualit� d'un tel dommage. Si votre pays n'autorise pas l'exclusion ou la limitation de responsabilit� pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l'exclusion ci-dessus ne s'appliquera pas � votre �gard. | ||
|
||
EFFET JURIDIQUE. Le pr�sent contrat d�crit certains droits juridiques. Vous pourriez avoir d'autres droits pr�vus par les lois de votre pays. Le pr�sent contrat ne modifie pas les droits que vous conf�rent les lois de votre pays si celles-ci ne le permettent pas. | ||
|
10 changes: 10 additions & 0 deletions
10
src/Platform/Microsoft.Testing.Extensions.HotReload/BannedSymbols.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
T:System.ArgumentNullException; Use 'Guard' instead | ||
P:System.DateTime.Now; Use 'IClock' instead | ||
P:System.DateTime.UtcNow; Use 'IClock' instead | ||
M:System.Threading.Tasks.Task.Run(System.Action); Use 'ITask' instead | ||
M:System.Threading.Tasks.Task.WhenAll(System.Threading.Tasks.Task[]); Use 'ITask' instead | ||
M:System.Threading.Tasks.Task.WhenAll(System.Collections.Generic.IEnumerable{System.Threading.Tasks.Task}); Use 'ITask' instead | ||
M:System.String.IsNullOrEmpty(System.String); Use 'RoslynString.IsNullOrEmpty' instead | ||
M:System.String.IsNullOrWhiteSpace(System.String); Use 'RoslynString.IsNullOrWhiteSpace' instead | ||
M:System.Diagnostics.Debug.Assert(System.Boolean); Use 'RoslynDebug.Assert' instead | ||
M:System.Diagnostics.Debug.Assert(System.Boolean,System.String); Use 'RoslynDebug.Assert' instead |
14 changes: 14 additions & 0 deletions
14
src/Platform/Microsoft.Testing.Extensions.HotReload/HotReloadExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
using Microsoft.Testing.Extensions.Hosting; | ||
using Microsoft.Testing.Platform.Builder; | ||
using Microsoft.Testing.Platform.TestHost; | ||
|
||
namespace Microsoft.Testing.Extensions; | ||
|
||
public static class HotReloadExtensions | ||
{ | ||
public static void AddHotReloadProvider(this ITestApplicationBuilder builder) | ||
=> ((TestHostManager)builder.TestHost).AddTestFrameworkInvoker(serviceProvider => | ||
new HotReloadTestHostTestFrameworkInvoker(serviceProvider)); | ||
} |
90 changes: 90 additions & 0 deletions
90
src/Platform/Microsoft.Testing.Extensions.HotReload/HotReloadHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
using Microsoft.Testing.Extensions.Hosting.Resources; | ||
using Microsoft.Testing.Platform.Helpers; | ||
using Microsoft.Testing.Platform.OutputDevice; | ||
using Microsoft.Testing.Platform.Extensions.OutputDevice; | ||
|
||
#if NETCOREAPP | ||
using System.Reflection.Metadata; | ||
|
||
using Microsoft.Testing.Extensions.Hosting; | ||
|
||
[assembly: MetadataUpdateHandler(typeof(HotReloadHandler))] | ||
#endif | ||
|
||
namespace Microsoft.Testing.Extensions.Hosting; | ||
|
||
internal sealed class HotReloadHandler | ||
{ | ||
private static readonly SemaphoreSlim SemaphoreSlim = new(1, 1); | ||
private static bool s_shutdownProcess; | ||
private readonly IConsole _console; | ||
private readonly IOutputDevice _outputDevice; | ||
private readonly IOutputDeviceDataProducer _outputDeviceDataProducer; | ||
|
||
public HotReloadHandler(IConsole console, IOutputDevice outputDevice, IOutputDeviceDataProducer outputDeviceDataProducer) | ||
{ | ||
_console = console; | ||
_outputDevice = outputDevice; | ||
_outputDeviceDataProducer = outputDeviceDataProducer; | ||
_console.CancelKeyPress += (_, _) => | ||
{ | ||
if (!s_shutdownProcess) | ||
{ | ||
s_shutdownProcess = true; | ||
SemaphoreSlim.Release(); | ||
} | ||
}; | ||
} | ||
|
||
// Called automatically by the runtime through the MetadataUpdateHandlerAttribute | ||
public static void ClearCache(Type[]? _) | ||
{ | ||
} | ||
|
||
// Called automatically by the runtime through the MetadataUpdateHandlerAttribute | ||
public static void UpdateApplication(Type[]? _) => SemaphoreSlim.Release(); | ||
|
||
#if !NET6_0_OR_GREATER | ||
public Task<bool> ShouldRunAsync(Task? waitExecutionCompletion, CancellationToken cancellationToken) | ||
{ | ||
// Avoid warnings about unused parameters and fields. | ||
_ = _outputDevice; | ||
_ = _outputDeviceDataProducer; | ||
_ = waitExecutionCompletion; | ||
_ = cancellationToken; | ||
throw new NotSupportedException(ExtensionResources.HotReloadHandlerUnsupportedFrameworkErrorMessage); | ||
} | ||
#else | ||
public async Task<bool> ShouldRunAsync(Task? waitExecutionCompletion, CancellationToken cancellationToken) | ||
{ | ||
if (s_shutdownProcess) | ||
{ | ||
return false; | ||
} | ||
|
||
cancellationToken.Register(() => s_shutdownProcess = true); | ||
|
||
if (waitExecutionCompletion is not null) | ||
{ | ||
await waitExecutionCompletion; | ||
await _outputDevice!.DisplayAsync(_outputDeviceDataProducer, new TextOutputDeviceData(ExtensionResources.HotReloadSessionCompleted)); | ||
} | ||
|
||
try | ||
{ | ||
await SemaphoreSlim.WaitAsync(cancellationToken); | ||
} | ||
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) | ||
{ | ||
// We're closing | ||
} | ||
|
||
_console!.Clear(); | ||
await _outputDevice.DisplayAsync(_outputDeviceDataProducer, new TextOutputDeviceData(ExtensionResources.HotReloadSessionStarted)); | ||
|
||
return !s_shutdownProcess; | ||
} | ||
#endif | ||
} |
Oops, something went wrong.