public ImmutableArray <ISymbolInternal> GetDeletedMethods(IDefinition containingType) { var containingSymbol = containingType.GetInternalSymbol()?.GetISymbol(); if (containingSymbol is null) { return(ImmutableArray <ISymbolInternal> .Empty); } if (!_deletedMembers.TryGetValue(containingSymbol, out var deleted)) { return(ImmutableArray <ISymbolInternal> .Empty); } return(ToInternalSymbolArray(deleted)); }
public SymbolChange GetChange(IDefinition def) { ISymbolInternal symbol = def.GetInternalSymbol(); var synthesizedDef = symbol as ISynthesizedMethodBodyImplementationSymbol; if (synthesizedDef != null) { Debug.Assert(synthesizedDef.Method != null); var generator = synthesizedDef.Method; ISymbolInternal synthesizedSymbol = synthesizedDef; var change = GetChange((IDefinition)generator.GetCciAdapter()); switch (change) { case SymbolChange.Updated: // The generator has been updated. Some synthesized members should be reused, others updated or added. // The container of the synthesized symbol doesn't exist, we need to add the symbol. // This may happen e.g. for members of a state machine type when a non-iterator method is changed to an iterator. if (!_definitionMap.DefinitionExists((IDefinition)synthesizedSymbol.ContainingType.GetCciAdapter())) { return(SymbolChange.Added); } if (!_definitionMap.DefinitionExists(def)) { // A method was changed to a method containing a lambda, to an iterator, or to an async method. // The state machine or closure class has been added. return(SymbolChange.Added); } // The existing symbol should be reused when the generator is updated, // not updated since it's form doesn't depend on the content of the generator. // For example, when an iterator method changes all methods that implement IEnumerable // but MoveNext can be reused as they are. if (!synthesizedDef.HasMethodBodyDependency) { return(SymbolChange.None); } // If the type produced from the method body existed before then its members are updated. if (synthesizedSymbol.Kind == SymbolKind.NamedType) { return(SymbolChange.ContainsChanges); } if (synthesizedSymbol.Kind == SymbolKind.Method) { // The method body might have been updated. return(SymbolChange.Updated); } return(SymbolChange.None); case SymbolChange.Added: // The method has been added - add the synthesized member as well, unless they already exist. if (!_definitionMap.DefinitionExists(def)) { return(SymbolChange.Added); } // If the existing member is a type we need to add new members into it. // An example is a shared static display class - an added method with static lambda will contribute // the lambda and cache fields into the shared display class. if (synthesizedSymbol.Kind == SymbolKind.NamedType) { return(SymbolChange.ContainsChanges); } // Update method. // An example is a constructor a shared display class - an added method with lambda will contribute // cache field initialization code into the constructor. if (synthesizedSymbol.Kind == SymbolKind.Method) { return(SymbolChange.Updated); } // Otherwise, there is nothing to do. // For example, a static lambda display class cache field. return(SymbolChange.None); default: // The method had to change, otherwise the synthesized symbol wouldn't be generated throw ExceptionUtilities.UnexpectedValue(change); } } if (symbol is object) { return(GetChange(symbol.GetISymbol())); } // If the def existed in the previous generation, the def is unchanged // (although it may contain changed defs); otherwise, it was added. if (_definitionMap.DefinitionExists(def)) { return((def is ITypeDefinition) ? SymbolChange.ContainsChanges : SymbolChange.None); } return(SymbolChange.Added); }
public bool IsReplaced(IDefinition definition) { var symbol = definition.GetInternalSymbol(); return(symbol is not null && _replacedSymbols.Contains(symbol.GetISymbol())); }