Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Fix for TypeExtensionPoint in generic classes #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions Mono.Addins/Mono.Addins.Database/AddinUpdateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,36 @@ void RegisterObjectTypes (ExtensionPoint ep)
public void RegisterExtension (AddinDescription description, ModuleDescription module, Extension extension)
{
if (extension.Path.StartsWith ("$")) {
string[] objectTypes = extension.Path.Substring (1).Split (',');
string path = extension.Path.Substring (1);
bool found = false;
foreach (string s in objectTypes) {
int searchIdx = 0;
do {
// Get the next type name, the delimiter is the comma
string typeName;

// REMARKS: For generic types, there could be commas inside the
// type parameter definition, we want to skip this.
// Generic types has [[ after generic name and ends with ]].
int genericStartIdx = path.IndexOf ("[[", searchIdx);
int separatorIdx = path.IndexOf (",", searchIdx);
if (genericStartIdx != -1 && genericStartIdx < separatorIdx) {
// This is a generic type so skip the types between [ ]
typeName = path.Substring (searchIdx, genericStartIdx - searchIdx);
searchIdx += path.IndexOf ("]]", searchIdx) + 3;
} else {
// Regular type
if (separatorIdx == -1)
separatorIdx = path.Length;
typeName = path.Substring (searchIdx, separatorIdx - searchIdx);
searchIdx += typeName.Length + 1;
}

// We have reached the end
if (searchIdx >= path.Length)
searchIdx = -1;

List<ExtensionPoint> list;
if (objectTypeExtensions.TryGetValue (s, out list)) {
if (objectTypeExtensions.TryGetValue (typeName, out list)) {
found = true;
foreach (ExtensionPoint ep in list) {
if (IsAddinCompatible (ep.ParentAddinDescription, description, module)) {
Expand All @@ -160,7 +185,8 @@ public void RegisterExtension (AddinDescription description, ModuleDescription m
}
}
}
}
} while (searchIdx != -1);

if (!found)
monitor.ReportWarning ("The add-in '" + description.AddinId + "' is trying to register the class '" + extension.Path.Substring (1) + "', but there isn't any add-in defining a suitable extension point");
}
Expand Down