Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2018-03-01 17:29:42 +0300
committerLluis Sanchez <lluis@xamarin.com>2018-03-01 17:29:42 +0300
commit65998888ebe45a57e057f55d2e14ed3beba70e58 (patch)
treee7bdf643dc6e4dba5e297b1e973a677e5c10ce74 /Mono.Addins/Mono.Addins.Database
parent136a3322119e147fa69d9a5a74a7a64da2199ce5 (diff)
Tweak add-in loading logic
If the same addin with same version exists in the app folder and in the user's addins folder, always load the one in the user's folder. This will make it easier to test add-ins running on apps that bundle the same version of the add-in.
Diffstat (limited to 'Mono.Addins/Mono.Addins.Database')
-rw-r--r--Mono.Addins/Mono.Addins.Database/AddinDatabase.cs46
1 files changed, 33 insertions, 13 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs b/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs
index 07891da..3822d82 100644
--- a/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs
+++ b/Mono.Addins/Mono.Addins.Database/AddinDatabase.cs
@@ -351,26 +351,46 @@ namespace Mono.Addins.Database
if (dbLockCheck)
InternalCheck (domain);
-
+
+ string version, name;
+ Addin.GetIdParts (id, out name, out version);
+
using ((dbLockCheck ? fileDatabase.LockRead () : null))
{
- string path = GetDescriptionPath (domain, id);
- if (sinfo == null && fileDatabase.Exists (path)) {
- sinfo = new Addin (this, domain, id);
- cachedAddinSetupInfos [idd] = sinfo;
- if (!enabledOnly || sinfo.Enabled)
- return sinfo;
- if (exactVersionMatch) {
- // Cache lookups with negative result
- cachedAddinSetupInfos [idd] = this;
- return null;
+ if (sinfo == null && !string.IsNullOrEmpty (version)) {
+ // If the same add-in with same version exists in both the global domain and the private domain,
+ // take the instance in the global domain. This is an edge case, since in general add-ins will
+ // have different versions. Taking the one from global domain in case of colision makes
+ // it easier to "replace" an add-in bundled in an app for unit testing purposes.
+ // So, look for an exact match in the global domain first:
+
+ string foundDomain = null;
+
+ string path = GetDescriptionPath (GlobalDomain, id);
+ if (fileDatabase.Exists (path))
+ foundDomain = GlobalDomain;
+ else {
+ path = GetDescriptionPath (domain, id);
+ if (fileDatabase.Exists (path))
+ foundDomain = domain;
+ }
+ if (foundDomain != null) {
+ sinfo = new Addin (this, foundDomain, id);
+ cachedAddinSetupInfos [idd] = sinfo;
+ if (!enabledOnly || sinfo.Enabled)
+ return sinfo;
+ if (exactVersionMatch) {
+ // Cache lookups with negative result
+ cachedAddinSetupInfos [idd] = this;
+ return null;
+ }
}
}
-
+
// Exact version not found. Look for a compatible version
if (!exactVersionMatch) {
sinfo = null;
- string version, name, bestVersion = null;
+ string bestVersion = null;
Addin.GetIdParts (id, out name, out version);
foreach (Addin ia in InternalGetInstalledAddins (domain, name, AddinSearchFlagsInternal.IncludeAll))