diff --git a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
index 8d3905e595..30d194fa34 100644
--- a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
+++ b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
@@ -221,6 +221,7 @@
+
diff --git a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
index ba64f7f3b7..4b27679d57 100644
--- a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
@@ -38,6 +38,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Gets/Sets the documentation provider that is used to retrive the XML documentation for all members.
///
public IDocumentationProvider DocumentationProvider { get; set; }
+
+ ///
+ /// Gets/Sets the interning provider.
+ ///
+ public IInterningProvider InterningProvider { get; set; }
#endregion
#region Load From AssemblyDefinition
@@ -47,12 +52,16 @@ namespace ICSharpCode.NRefactory.TypeSystem
throw new ArgumentNullException("assemblyDefinition");
ITypeResolveContext oldEarlyBindContext = this.EarlyBindContext;
try {
- List assemblyAttributes = new List();
+ IList assemblyAttributes = new List();
foreach (var attr in assemblyDefinition.CustomAttributes) {
assemblyAttributes.Add(ReadAttribute(attr));
}
+ if (this.InterningProvider != null)
+ assemblyAttributes = this.InterningProvider.InternList(assemblyAttributes);
+ else
+ assemblyAttributes = new ReadOnlyCollection(assemblyAttributes);
TypeStorage typeStorage = new TypeStorage();
- CecilProjectContent pc = new CecilProjectContent(typeStorage, assemblyDefinition.Name.FullName, assemblyAttributes.AsReadOnly(), this.DocumentationProvider);
+ CecilProjectContent pc = new CecilProjectContent(typeStorage, assemblyDefinition.Name.FullName, assemblyAttributes, this.DocumentationProvider);
this.EarlyBindContext = CompositeTypeResolveContext.Combine(pc, this.EarlyBindContext);
List types = new List();
@@ -105,10 +114,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
sealed class CecilProjectContent : ProxyTypeResolveContext, IProjectContent, ISynchronizedTypeResolveContext, IDocumentationProvider
{
readonly string assemblyName;
- readonly ReadOnlyCollection assemblyAttributes;
+ readonly IList assemblyAttributes;
readonly IDocumentationProvider documentationProvider;
- public CecilProjectContent(TypeStorage types, string assemblyName, ReadOnlyCollection assemblyAttributes, IDocumentationProvider documentationProvider)
+ public CecilProjectContent(TypeStorage types, string assemblyName, IList assemblyAttributes, IDocumentationProvider documentationProvider)
: base(types)
{
Debug.Assert(assemblyName != null);
@@ -710,6 +719,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
}
+ if (this.InterningProvider != null)
+ m = this.InterningProvider.Intern(m);
return m;
}
@@ -830,6 +841,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
f.IsVolatile = true;
}
+ if (this.InterningProvider != null)
+ f = this.InterningProvider.Intern(f);
return f;
}
@@ -897,6 +910,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
AddAttributes(property, p);
+ if (this.InterningProvider != null)
+ p = this.InterningProvider.Intern(p);
return p;
}
@@ -936,6 +951,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
AddAttributes(ev, e);
+ if (this.InterningProvider != null)
+ e = this.InterningProvider.Intern(e);
return e;
}
#endregion
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleInterningProvider.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleInterningProvider.cs
new file mode 100644
index 0000000000..66f6aeb172
--- /dev/null
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleInterningProvider.cs
@@ -0,0 +1,122 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+
+using ICSharpCode.NRefactory.Utils;
+
+namespace ICSharpCode.NRefactory.TypeSystem.Implementation
+{
+ ///
+ /// Simple interning provider.
+ ///
+ public sealed class SimpleInterningProvider : IInterningProvider
+ {
+ sealed class ReferenceComparer : IEqualityComparer