Browse Source

CecilLoader: add support for reading module attributes, security declarations and marshal information.

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
21d2121ae5
  1. 9
      ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.cs
  2. 6
      ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs
  3. 2
      ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
  4. 151
      ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
  5. 5
      ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs
  6. 5
      ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs
  7. 11
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAttribute.cs
  8. 34
      ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs

9
ICSharpCode.NRefactory/CSharp/Analysis/MinimalResolveContext.cs

@ -23,7 +23,6 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -23,7 +23,6 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
}
readonly ReadOnlyCollection<string> namespaces = Array.AsReadOnly(new string[] { "System" });
readonly IAttribute[] assemblyAttributes = new IAttribute[0];
readonly ITypeDefinition systemObject, systemValueType;
readonly ReadOnlyCollection<ITypeDefinition> types;
@ -101,8 +100,12 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis @@ -101,8 +100,12 @@ namespace ICSharpCode.NRefactory.CSharp.Analysis
return null;
}
public IList<IAttribute> AssemblyAttributes {
get { return assemblyAttributes; }
IList<IAttribute> IProjectContent.AssemblyAttributes {
get { return EmptyList<IAttribute>.Instance; }
}
IList<IAttribute> IProjectContent.ModuleAttributes {
get { return EmptyList<IAttribute>.Instance; }
}
ICSharpCode.NRefactory.Utils.CacheManager ITypeResolveContext.CacheManager {

6
ICSharpCode.NRefactory/CSharp/Parser/ParsedFile.cs

@ -18,6 +18,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -18,6 +18,7 @@ namespace ICSharpCode.NRefactory.CSharp
readonly UsingScope rootUsingScope;
IList<ITypeDefinition> topLevelTypeDefinitions = new List<ITypeDefinition>();
IList<IAttribute> assemblyAttributes = new List<IAttribute>();
IList<IAttribute> moduleAttributes = new List<IAttribute>();
IList<UsingScope> usingScopes = new List<UsingScope>();
IList<Error> errors = new List<Error> ();
@ -27,6 +28,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -27,6 +28,7 @@ namespace ICSharpCode.NRefactory.CSharp
rootUsingScope.Freeze();
topLevelTypeDefinitions = FreezeList(topLevelTypeDefinitions);
assemblyAttributes = FreezeList(assemblyAttributes);
moduleAttributes = FreezeList(moduleAttributes);
usingScopes = FreezeList(usingScopes);
}
@ -76,6 +78,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -76,6 +78,10 @@ namespace ICSharpCode.NRefactory.CSharp
get { return assemblyAttributes; }
}
public IList<IAttribute> ModuleAttributes {
get { return moduleAttributes; }
}
public UsingScope GetUsingScope(AstLocation location)
{
foreach (UsingScope scope in usingScopes) {

2
ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs

@ -638,6 +638,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -638,6 +638,8 @@ namespace ICSharpCode.NRefactory.CSharp
// non-assembly attributes are handled by their parent entity
if (attributeSection.AttributeTarget == "assembly") {
ConvertAttributes(parsedFile.AssemblyAttributes, attributeSection);
} else if (attributeSection.AttributeTarget == "module") {
ConvertAttributes(parsedFile.ModuleAttributes, attributeSection);
}
return null;
}

151
ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs

@ -8,6 +8,7 @@ using System.Diagnostics; @@ -8,6 +8,7 @@ using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using Mono.Cecil;
@ -76,16 +77,21 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -76,16 +77,21 @@ namespace ICSharpCode.NRefactory.TypeSystem
throw new ArgumentNullException("assemblyDefinition");
ITypeResolveContext oldEarlyBindContext = this.EarlyBindContext;
try {
// Read assembly attributes
// Read assembly and module attributes
IList<IAttribute> assemblyAttributes = new List<IAttribute>();
IList<IAttribute> moduleAttributes = new List<IAttribute>();
AddAttributes(assemblyDefinition, assemblyAttributes);
AddAttributes(assemblyDefinition.MainModule, moduleAttributes);
if (this.InterningProvider != null)
if (this.InterningProvider != null) {
assemblyAttributes = this.InterningProvider.InternList(assemblyAttributes);
else
moduleAttributes = this.InterningProvider.InternList(moduleAttributes);
} else {
assemblyAttributes = new ReadOnlyCollection<IAttribute>(assemblyAttributes);
moduleAttributes = new ReadOnlyCollection<IAttribute>(moduleAttributes);
}
TypeStorage typeStorage = new TypeStorage();
CecilProjectContent pc = new CecilProjectContent(typeStorage, assemblyDefinition.Name.FullName, assemblyAttributes, this.DocumentationProvider);
CecilProjectContent pc = new CecilProjectContent(typeStorage, assemblyDefinition.Name.FullName, assemblyAttributes, moduleAttributes, this.DocumentationProvider);
this.EarlyBindContext = CompositeTypeResolveContext.Combine(pc, this.EarlyBindContext);
List<CecilTypeDefinition> types = new List<CecilTypeDefinition>();
@ -141,15 +147,18 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -141,15 +147,18 @@ namespace ICSharpCode.NRefactory.TypeSystem
{
readonly string assemblyName;
readonly IList<IAttribute> assemblyAttributes;
readonly IList<IAttribute> moduleAttributes;
readonly IDocumentationProvider documentationProvider;
public CecilProjectContent(TypeStorage types, string assemblyName, IList<IAttribute> assemblyAttributes, IDocumentationProvider documentationProvider)
public CecilProjectContent(TypeStorage types, string assemblyName, IList<IAttribute> assemblyAttributes, IList<IAttribute> moduleAttributes, IDocumentationProvider documentationProvider)
: base(types)
{
Debug.Assert(assemblyName != null);
Debug.Assert(assemblyAttributes != null);
Debug.Assert(moduleAttributes != null);
this.assemblyName = assemblyName;
this.assemblyAttributes = assemblyAttributes;
this.moduleAttributes = moduleAttributes;
this.documentationProvider = documentationProvider;
}
@ -157,6 +166,10 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -157,6 +166,10 @@ namespace ICSharpCode.NRefactory.TypeSystem
get { return assemblyAttributes; }
}
public IList<IAttribute> ModuleAttributes {
get { return moduleAttributes; }
}
public override string ToString()
{
return "[CecilProjectContent " + assemblyName + "]";
@ -359,12 +372,23 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -359,12 +372,23 @@ namespace ICSharpCode.NRefactory.TypeSystem
#region Read Attributes
#region Assembly Attributes
static readonly ITypeReference typeForwardedToAttributeTypeRef = typeof(TypeForwardedToAttribute).ToTypeReference();
static readonly ITypeReference assemblyVersionAttributeTypeRef = typeof(System.Reflection.AssemblyVersionAttribute).ToTypeReference();
void AddAttributes(AssemblyDefinition assembly, IList<IAttribute> outputList)
{
if (assembly.HasCustomAttributes) {
AddCustomAttributes(assembly.CustomAttributes, outputList);
}
if (assembly.HasSecurityDeclarations) {
AddSecurityAttributes(assembly.SecurityDeclarations, outputList);
}
// AssemblyVersionAttribute
if (assembly.Name.Version != null) {
var assemblyVersion = new DefaultAttribute(assemblyVersionAttributeTypeRef, new[] { KnownTypeReference.String });
assemblyVersion.PositionalArguments.Add(new SimpleConstantValue(KnownTypeReference.String, assembly.Name.Version.ToString()));
outputList.Add(assemblyVersion);
}
// TypeForwardedToAttribute
foreach (ExportedType type in assembly.MainModule.ExportedTypes) {
@ -380,6 +404,15 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -380,6 +404,15 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
#endregion
#region Module Attributes
void AddAttributes(ModuleDefinition module, IList<IAttribute> outputList)
{
if (module.HasCustomAttributes) {
AddCustomAttributes(module.CustomAttributes, outputList);
}
}
#endregion
#region Parameter Attributes
static readonly IAttribute inAttribute = new DefaultAttribute(typeof(InAttribute).ToTypeReference(), null);
static readonly IAttribute outAttribute = new DefaultAttribute(typeof(OutAttribute).ToTypeReference(), null);
@ -395,6 +428,9 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -395,6 +428,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
if (parameter.HasCustomAttributes) {
AddCustomAttributes(parameter.CustomAttributes, targetParameter.Attributes);
}
if (parameter.HasMarshalInfo) {
targetParameter.Attributes.Add(ConvertMarshalInfo(parameter.MarshalInfo));
}
}
#endregion
@ -429,9 +465,9 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -429,9 +465,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
dllImport.PositionalArguments.Add(new SimpleConstantValue(KnownTypeReference.String, info.Module.Name));
if (info.IsBestFitDisabled)
AddNamedArgument(dllImport, "BestFitMapping", falseValue);
dllImport.AddNamedArgument("BestFitMapping", falseValue);
if (info.IsBestFitEnabled)
AddNamedArgument(dllImport, "BestFitMapping", trueValue);
dllImport.AddNamedArgument("BestFitMapping", trueValue);
CallingConvention callingConvention;
switch (info.Attributes & PInvokeAttributes.CallConvMask) {
@ -454,7 +490,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -454,7 +490,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
throw new NotSupportedException("unknown calling convention");
}
if (callingConvention != CallingConvention.Winapi)
AddNamedArgument(dllImport, "CallingConvention", new SimpleConstantValue(callingConventionTypeRef, (int)callingConvention));
dllImport.AddNamedArgument("CallingConvention", callingConventionTypeRef, (int)callingConvention);
CharSet charSet = CharSet.None;
switch (info.Attributes & PInvokeAttributes.CharSetMask) {
@ -469,27 +505,26 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -469,27 +505,26 @@ namespace ICSharpCode.NRefactory.TypeSystem
break;
}
if (charSet != CharSet.None)
dllImport.NamedArguments.Add(new KeyValuePair<string, IConstantValue>(
"CharSet", new SimpleConstantValue(charSetTypeRef, (int)charSet)));
dllImport.AddNamedArgument("CharSet", charSetTypeRef, (int)charSet);
if (!string.IsNullOrEmpty(info.EntryPoint) && info.EntryPoint != methodDefinition.Name)
AddNamedArgument(dllImport, "EntryPoint", new SimpleConstantValue(KnownTypeReference.String, info.EntryPoint));
dllImport.AddNamedArgument("EntryPoint", KnownTypeReference.String, info.EntryPoint);
if (info.IsNoMangle)
AddNamedArgument(dllImport, "ExactSpelling", trueValue);
dllImport.AddNamedArgument("ExactSpelling", trueValue);
if ((implAttributes & MethodImplAttributes.PreserveSig) == MethodImplAttributes.PreserveSig)
implAttributes &= ~MethodImplAttributes.PreserveSig;
else
AddNamedArgument(dllImport, "PreserveSig", falseValue);
dllImport.AddNamedArgument("PreserveSig", falseValue);
if (info.SupportsLastError)
AddNamedArgument(dllImport, "SetLastError", trueValue);
dllImport.AddNamedArgument("SetLastError", trueValue);
if (info.IsThrowOnUnmappableCharDisabled)
AddNamedArgument(dllImport, "ThrowOnUnmappableChar", falseValue);
dllImport.AddNamedArgument("ThrowOnUnmappableChar", falseValue);
if (info.IsThrowOnUnmappableCharEnabled)
AddNamedArgument(dllImport, "ThrowOnUnmappableChar", trueValue);
dllImport.AddNamedArgument("ThrowOnUnmappableChar", trueValue);
attributes.Add(dllImport);
}
@ -513,6 +548,9 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -513,6 +548,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
if (methodDefinition.HasCustomAttributes) {
AddCustomAttributes(methodDefinition.CustomAttributes, attributes);
}
if (methodDefinition.HasSecurityDeclarations) {
AddSecurityAttributes(methodDefinition.SecurityDeclarations, attributes);
}
if (methodDefinition.MethodReturnType.HasMarshalInfo) {
returnTypeAttributes.Add(ConvertMarshalInfo(methodDefinition.MethodReturnType.MarshalInfo));
}
@ -520,11 +558,6 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -520,11 +558,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
AddCustomAttributes(methodDefinition.MethodReturnType.CustomAttributes, returnTypeAttributes);
}
}
static void AddNamedArgument(DefaultAttribute attribute, string name, IConstantValue value)
{
attribute.NamedArguments.Add(new KeyValuePair<string, IConstantValue>(name, value));
}
#endregion
#region Type Attributes
@ -571,19 +604,13 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -571,19 +604,13 @@ namespace ICSharpCode.NRefactory.TypeSystem
DefaultAttribute structLayout = new DefaultAttribute(structLayoutAttributeTypeRef, new[] { layoutKindTypeRef });
structLayout.PositionalArguments.Add(new SimpleConstantValue(layoutKindTypeRef, (int)layoutKind));
if (charSet != CharSet.Ansi) {
structLayout.NamedArguments.Add(new KeyValuePair<string, IConstantValue>(
"CharSet",
new SimpleConstantValue(charSetTypeRef, (int)charSet)));
structLayout.AddNamedArgument("CharSet", charSetTypeRef, (int)charSet);
}
if (typeDefinition.PackingSize > 0) {
structLayout.NamedArguments.Add(new KeyValuePair<string, IConstantValue>(
"Pack",
new SimpleConstantValue(KnownTypeReference.Int32, (int)typeDefinition.PackingSize)));
structLayout.AddNamedArgument("Pack", KnownTypeReference.Int32, (int)typeDefinition.PackingSize);
}
if (typeDefinition.ClassSize > 0) {
structLayout.NamedArguments.Add(new KeyValuePair<string, IConstantValue>(
"Size",
new SimpleConstantValue(KnownTypeReference.Int32, (int)typeDefinition.ClassSize)));
structLayout.AddNamedArgument("Size", KnownTypeReference.Int32, (int)typeDefinition.ClassSize);
}
targetEntity.Attributes.Add(structLayout);
}
@ -592,6 +619,9 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -592,6 +619,9 @@ namespace ICSharpCode.NRefactory.TypeSystem
if (typeDefinition.HasCustomAttributes) {
AddCustomAttributes(typeDefinition.CustomAttributes, targetEntity.Attributes);
}
if (typeDefinition.HasSecurityDeclarations) {
AddSecurityAttributes(typeDefinition.SecurityDeclarations, targetEntity.Attributes);
}
}
#endregion
@ -649,7 +679,37 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -649,7 +679,37 @@ namespace ICSharpCode.NRefactory.TypeSystem
{
DefaultAttribute attr = new DefaultAttribute(marshalAsAttributeTypeRef, new[] { unmanagedTypeTypeRef });
attr.PositionalArguments.Add(new SimpleConstantValue(unmanagedTypeTypeRef, (int)marshalInfo.NativeType));
// TODO: handle classes derived from MarshalInfo
FixedArrayMarshalInfo fami = marshalInfo as FixedArrayMarshalInfo;
if (fami != null) {
attr.AddNamedArgument("SizeConst", KnownTypeReference.Int32, (int)fami.Size);
if (fami.ElementType != NativeType.None)
attr.AddNamedArgument("ArraySubType", unmanagedTypeTypeRef, (int)fami.ElementType);
}
SafeArrayMarshalInfo sami = marshalInfo as SafeArrayMarshalInfo;
if (sami != null && sami.ElementType != VariantType.None) {
attr.AddNamedArgument("SafeArraySubType", typeof(VarEnum).ToTypeReference(), (int)sami.ElementType);
}
ArrayMarshalInfo ami = marshalInfo as ArrayMarshalInfo;
if (ami != null) {
if (ami.ElementType != NativeType.Max)
attr.AddNamedArgument("ArraySubType", unmanagedTypeTypeRef, (int)ami.ElementType);
if (ami.Size >= 0)
attr.AddNamedArgument("SizeConst", KnownTypeReference.Int32, (int)ami.Size);
if (ami.SizeParameterMultiplier != 0 && ami.SizeParameterIndex >= 0)
attr.AddNamedArgument("SizeParamIndex", KnownTypeReference.Int16, (short)ami.SizeParameterIndex);
}
CustomMarshalInfo cmi = marshalInfo as CustomMarshalInfo;
if (cmi != null) {
attr.AddNamedArgument("MarshalType", KnownTypeReference.String, cmi.ManagedType.FullName);
if (!string.IsNullOrEmpty(cmi.Cookie))
attr.AddNamedArgument("MarshalCookie", KnownTypeReference.String, cmi.Cookie);
}
FixedSysStringMarshalInfo fssmi = marshalInfo as FixedSysStringMarshalInfo;
if (fssmi != null) {
attr.AddNamedArgument("SizeConst", KnownTypeReference.Int32, (int)fssmi.Size);
}
return attr;
}
#endregion
@ -706,6 +766,35 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -706,6 +766,35 @@ namespace ICSharpCode.NRefactory.TypeSystem
return a;
}
#endregion
#region Security Attributes
static readonly ITypeReference securityActionTypeReference = typeof(SecurityAction).ToTypeReference();
void AddSecurityAttributes(Mono.Collections.Generic.Collection<SecurityDeclaration> securityDeclarations, IList<IAttribute> targetCollection)
{
foreach (var secDecl in securityDeclarations) {
foreach (var secAttribute in secDecl.SecurityAttributes) {
ITypeReference attributeType = ReadTypeReference(secAttribute.AttributeType);
var a = new DefaultAttribute(attributeType, new[] { securityActionTypeReference });
a.PositionalArguments.Add(new SimpleConstantValue(securityActionTypeReference, (ushort)secDecl.Action));
try {
if (secAttribute.HasFields || secAttribute.HasProperties) {
foreach (var arg in secAttribute.Fields) {
a.NamedArguments.Add(new KeyValuePair<string, IConstantValue>(arg.Name, ReadConstantValue(arg.Argument)));
}
foreach (var arg in secAttribute.Properties) {
a.NamedArguments.Add(new KeyValuePair<string, IConstantValue>(arg.Name, ReadConstantValue(arg.Argument)));
}
}
} catch (InvalidOperationException) {
// occurs when Cecil can't decode an argument
}
targetCollection.Add(a);
}
}
}
#endregion
#endregion
#region Read Constant Value

5
ICSharpCode.NRefactory/TypeSystem/IParsedFile.cs

@ -37,6 +37,11 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -37,6 +37,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
IList<IAttribute> AssemblyAttributes { get; }
/// <summary>
/// Gets all module attributes that are defined in this file.
/// </summary>
IList<IAttribute> ModuleAttributes { get; }
/// <summary>
/// Gets the top-level type defined at the specified location.
/// Returns null if no type is defined at that location.

5
ICSharpCode.NRefactory/TypeSystem/IProjectContent.cs

@ -20,6 +20,11 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -20,6 +20,11 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// </summary>
IList<IAttribute> AssemblyAttributes { get; }
/// <summary>
/// Gets the list of all module attributes in the project.
/// </summary>
IList<IAttribute> ModuleAttributes { get; }
/// <summary>
/// Gets a parsed file by its file name.
/// </summary>

11
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAttribute.cs

@ -163,5 +163,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -163,5 +163,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
DefaultAttribute a = other as DefaultAttribute;
return a != null && attributeType == a.attributeType && positionalArguments == a.positionalArguments && namedArguments == a.namedArguments && region == a.region;
}
public void AddNamedArgument(string name, ITypeReference type, object value)
{
AddNamedArgument(name, new SimpleConstantValue(type, value));
}
public void AddNamedArgument(string name, IConstantValue value)
{
CheckBeforeMutation();
this.NamedArguments.Add(new KeyValuePair<string, IConstantValue>(name, value));
}
}
}

34
ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleProjectContent.cs

@ -31,32 +31,50 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -31,32 +31,50 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
#region AssemblyAttributes
readonly List<IAttribute> assemblyAttributes = new List<IAttribute>(); // mutable assembly attribute storage
readonly List<IAttribute> moduleAttributes = new List<IAttribute>();
volatile IAttribute[] readOnlyAssemblyAttributes = {}; // volatile field with copy for reading threads
volatile IAttribute[] readOnlyModuleAttributes = {};
/// <inheritdoc/>
public IList<IAttribute> AssemblyAttributes {
get { return readOnlyAssemblyAttributes; }
}
void AddRemoveAssemblyAttributes(ICollection<IAttribute> removedAttributes, ICollection<IAttribute> addedAttributes)
/// <inheritdoc/>
public IList<IAttribute> ModuleAttributes {
get { return readOnlyModuleAttributes; }
}
static bool AddRemoveAttributes(ICollection<IAttribute> removedAttributes, ICollection<IAttribute> addedAttributes,
List<IAttribute> attributeStorage)
{
// API uses ICollection instead of IEnumerable to discourage users from evaluating
// the list inside the lock (this method is called inside the write lock)
// [[not an issue anymore; the user now passes IParsedFile]]
bool hasChanges = false;
if (removedAttributes != null && removedAttributes.Count > 0) {
if (assemblyAttributes.RemoveAll(removedAttributes.Contains) > 0)
if (attributeStorage.RemoveAll(removedAttributes.Contains) > 0)
hasChanges = true;
}
if (addedAttributes != null) {
assemblyAttributes.AddRange(addedAttributes);
attributeStorage.AddRange(addedAttributes);
hasChanges = true;
}
if (hasChanges)
return hasChanges;
}
void AddRemoveAssemblyAttributes(ICollection<IAttribute> removedAttributes, ICollection<IAttribute> addedAttributes)
{
if (AddRemoveAttributes(removedAttributes, addedAttributes, assemblyAttributes))
readOnlyAssemblyAttributes = assemblyAttributes.ToArray();
}
void AddRemoveModuleAttributes(ICollection<IAttribute> removedAttributes, ICollection<IAttribute> addedAttributes)
{
if (AddRemoveAttributes(removedAttributes, addedAttributes, moduleAttributes))
readOnlyModuleAttributes = moduleAttributes.ToArray();
}
#endregion
#region AddType
@ -110,7 +128,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -110,7 +128,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
}
fileDict[newFile.FileName] = newFile;
}
AddRemoveAssemblyAttributes(oldFile != null ? oldFile.AssemblyAttributes : null, newFile != null ? newFile.AssemblyAttributes : null);
AddRemoveAssemblyAttributes(oldFile != null ? oldFile.AssemblyAttributes : null,
newFile != null ? newFile.AssemblyAttributes : null);
AddRemoveModuleAttributes(oldFile != null ? oldFile.ModuleAttributes : null,
newFile != null ? newFile.ModuleAttributes : null);
} finally {
readerWriterLock.ExitWriteLock();
}

Loading…
Cancel
Save