Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal sealed class NodeFactory (MarkStep markStep)
public MarkStep MarkStep { get; } = markStep;
readonly NodeCache<TypeDefinition, TypeDefinitionNode> _typeNodes = new (static t => new TypeDefinitionNode(t));
readonly NodeCache<MethodDefinition, MethodDefinitionNode> _methodNodes = new (static _ => throw new InvalidOperationException ("Creation of node requires more than the key."));
readonly NodeCache<PropertyDefinition, PropertyDefinitionNode> _propertyNodes = new (static p => new PropertyDefinitionNode(p));
readonly NodeCache<TypeDefinition, TypeIsRelevantToVariantCastingNode> _typeIsRelevantToVariantCastingNodes = new (static (t) => new TypeIsRelevantToVariantCastingNode (t));

internal TypeDefinitionNode GetTypeNode (TypeDefinition definition)
Expand All @@ -32,6 +33,11 @@ internal TypeIsRelevantToVariantCastingNode GetTypeIsRelevantToVariantCastingNod
return _typeIsRelevantToVariantCastingNodes.GetOrAdd (type);
}

internal PropertyDefinitionNode GetPropertyNode (PropertyDefinition prop)
{
return _propertyNodes.GetOrAdd (prop);
}

struct NodeCache<TKey, TValue> where TKey : notnull
{
// Change to concurrent dictionary if/when multithreaded marking is enabled
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Generic;
using ILCompiler.DependencyAnalysisFramework;
using Mono.Cecil;

namespace Mono.Linker.Steps
{

public partial class MarkStep
{
internal sealed class PropertyDefinitionNode : DependencyNodeCore<NodeFactory>
{
PropertyDefinition _property;
public PropertyDefinitionNode(PropertyDefinition property)
{
_property = property;
}

public override bool InterestingForDynamicDependencyAnalysis => false;

public override bool HasDynamicDependencies => false;

public override bool HasConditionalStaticDependencies => false;

public override bool StaticDependenciesAreComputed => true;

public override IEnumerable<CombinedDependencyListEntry>? GetConditionalStaticDependencies (NodeFactory context) => null;

public override IEnumerable<DependencyListEntry>? GetStaticDependencies (NodeFactory context)
{
var propertyOrigin = new MessageOrigin (_property);

// Consider making this more similar to MarkEvent method?
context.MarkStep.MarkCustomAttributes (_property, new DependencyInfo (DependencyKind.CustomAttribute, _property), propertyOrigin);
context.MarkStep.DoAdditionalPropertyProcessing (_property);
return null;
}

public override IEnumerable<CombinedDependencyListEntry>? SearchDynamicDependencies (List<DependencyNodeCore<NodeFactory>> markedNodes, int firstNode, NodeFactory context) => null;

protected override string GetName (NodeFactory context) => _property.GetDisplayName ();
}
}
}
7 changes: 2 additions & 5 deletions src/tools/illink/src/linker/Linker.Steps/MarkStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3498,11 +3498,8 @@ protected internal void MarkProperty (PropertyDefinition prop, in DependencyInfo
if (!Annotations.MarkProcessed (prop, reason))
return;

var propertyOrigin = new MessageOrigin (prop);

// Consider making this more similar to MarkEvent method?
MarkCustomAttributes (prop, new DependencyInfo (DependencyKind.CustomAttribute, prop), propertyOrigin);
DoAdditionalPropertyProcessing (prop);
PropertyDefinitionNode propertyNode = _nodeFactory.GetPropertyNode (prop);
_dependencyGraph.AddRoot (propertyNode, reason.Kind.ToString ());
}

protected internal virtual void MarkEvent (EventDefinition evt, in DependencyInfo reason, MessageOrigin origin)
Expand Down