Skip to content
Open
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 @@ -29,7 +29,13 @@ public GenericParameterConstraintNode(EcmaModule module, GenericParameterConstra
public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory factory)
{
GenericParameterConstraint genericParamConstraint = _module.MetadataReader.GetGenericParameterConstraint(Handle);
yield return new DependencyListEntry(factory.GetNodeForTypeToken(_module, genericParamConstraint.Type), "Parameter constrained to type");

DependencyList dependencies = new DependencyList();
dependencies.Add(factory.GetNodeForTypeToken(_module, genericParamConstraint.Type), "Parameter constrained to type");

CustomAttributeNode.AddDependenciesDueToCustomAttributes(ref dependencies, factory, _module, genericParamConstraint.GetCustomAttributes());

return dependencies;
}

protected override EntityHandle WriteInternal(ModuleWritingContext writeContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,18 @@ public GenericParameterNode(EcmaModule module, GenericParameterHandle handle)
public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory factory)
{
GenericParameter genericParam = _module.MetadataReader.GetGenericParameter(Handle);

DependencyList dependencies = null;

foreach (var genericParamConstrain in genericParam.GetConstraints())
{
yield return new DependencyListEntry(factory.GenericParameterConstraint(_module, genericParamConstrain), "Generic Parameter Constraint of Generic Parameter");
dependencies ??= new DependencyList();
dependencies.Add(factory.GenericParameterConstraint(_module, genericParamConstrain), "Generic Parameter Constraint of Generic Parameter");
}

CustomAttributeNode.AddDependenciesDueToCustomAttributes(ref dependencies, factory, _module, genericParam.GetCustomAttributes());

return dependencies;
}

protected override EntityHandle WriteInternal(ModuleWritingContext writeContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto

_skipWritingResource = false;

DependencyList dependencies = null;

if (resource.Implementation.IsNil)
{
string resourceName = _module.MetadataReader.GetString(resource.Name);
Expand All @@ -40,29 +42,25 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto
string assemblyName = _module.Assembly.GetName().Name;
_skipWritingResource = factory.Settings.Optimizations.IsEnabled(CodeOptimizations.RemoveDescriptors, assemblyName);

if (factory.Settings.IgnoreDescriptors)
return null;
if (!factory.Settings.IgnoreDescriptors)
{
PEMemoryBlock resourceDirectory = _module.PEReader.GetSectionData(_module.PEReader.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress);
BlobReader reader = resourceDirectory.GetReader((int)resource.Offset, resourceDirectory.Length - (int)resource.Offset);
int length = (int)reader.ReadUInt32();

PEMemoryBlock resourceDirectory = _module.PEReader.GetSectionData(_module.PEReader.PEHeaders.CorHeader.ResourcesDirectory.RelativeVirtualAddress);
BlobReader reader = resourceDirectory.GetReader((int)resource.Offset, resourceDirectory.Length - (int)resource.Offset);
int length = (int)reader.ReadUInt32();
UnmanagedMemoryStream ms;
unsafe
{
ms = new UnmanagedMemoryStream(reader.CurrentPointer, length);
}

UnmanagedMemoryStream ms;
unsafe
{
ms = new UnmanagedMemoryStream(reader.CurrentPointer, length);
dependencies = DescriptorMarker.GetDependencies(factory.Logger, factory, ms, resource, _module, "resource " + resourceName + " in " + _module.ToString(), factory.Settings.FeatureSettings);
}

return DescriptorMarker.GetDependencies(factory.Logger, factory, ms, resource, _module, "resource " + resourceName + " in " + _module.ToString(), factory.Settings.FeatureSettings);
}
else
{
return null;
}
}
else
{
DependencyList dependencies = new();
dependencies = new();
switch (resource.Implementation.Kind)
{
case HandleKind.AssemblyReference:
Expand All @@ -73,8 +71,10 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto
// TODO: Handle AssemblyFile
throw new InvalidOperationException(resource.Implementation.Kind.ToString());
}
return dependencies;
}

CustomAttributeNode.AddDependenciesDueToCustomAttributes(ref dependencies, factory, _module, resource.GetCustomAttributes());
return dependencies;
Comment thread
MichalStrehovsky marked this conversation as resolved.
}

public override void BuildTokens(TokenMap.Builder builder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ public ParameterNode(EcmaModule module, ParameterHandle handle)

private ParameterHandle Handle => (ParameterHandle)_handle;

public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory context) => null;
public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory context)
{
DependencyList dependencies = null;

Parameter parameter = _module.MetadataReader.GetParameter(Handle);
CustomAttributeNode.AddDependenciesDueToCustomAttributes(ref dependencies, context, _module, parameter.GetCustomAttributes());

return dependencies;
}

public override string ToString()
{
Expand Down
25 changes: 5 additions & 20 deletions src/coreclr/tools/ILTrim.Tests/ILTrimExpectedFailures.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Advanced.TypeCheckRemoval
Attributes.AssemblyAttributeAccessesMembers
Attributes.AssemblyAttributeIsRemovedIfOnlyTypesUsedInAssembly
Attributes.AttributeOnParameterInUsedMethodIsKept
Attributes.AttributeOnPreservedTypeWithTypeUsedInConstructorIsKept
Attributes.AttributeOnPreservedTypeWithTypeUsedInDifferentNamespaceIsKept
Attributes.AttributeOnPreservedTypeWithTypeUsedInFieldIsKept
Expand Down Expand Up @@ -54,16 +53,20 @@ Attributes.OnlyKeepUsed.AttributeUsedByAttributeIsKept
Attributes.OnlyKeepUsed.CanLinkCoreLibrariesWithOnlyKeepUsedAttributes
Attributes.OnlyKeepUsed.CoreLibraryUnusedAssemblyAttributesAreRemoved
Attributes.OnlyKeepUsed.CoreLibraryUsedAssemblyAttributesAreKept
Attributes.OnlyKeepUsed.MethodWithUnmanagedConstraint
Attributes.OnlyKeepUsed.NullableOnConstraintsKept
Attributes.OnlyKeepUsed.NullableOnConstraintsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeOnGenericParameterIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeOnReturnTypeIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeTypeOnAssemblyIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeTypeOnEventIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeTypeOnMethodIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeTypeOnModuleIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeTypeOnParameterIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeTypeOnPropertyIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeTypeOnTypeIsRemoved
Attributes.OnlyKeepUsed.UnusedAttributeWithTypeForwarderIsRemoved
Attributes.OnlyKeepUsed.UnusedDerivedAttributeType
Attributes.OnlyKeepUsed.UsedAttributeTypeOnParameterIsKept
Attributes.SecurityAttributesOnUsedMethodAreKept
Attributes.SecurityAttributesOnUsedTypeAreKept
Attributes.StructLayout.ExplicitClass
Expand Down Expand Up @@ -95,9 +98,7 @@ DataFlow.AnnotatedMembersAccessedViaUnsafeAccessor
DataFlow.ApplyTypeAnnotations
DataFlow.AttributeConstructorDataflow
DataFlow.AttributeFieldDataflow
DataFlow.AttributePrimaryConstructorDataflow
DataFlow.AttributePropertyDataflow
DataFlow.ByRefDataflow
DataFlow.CompilerGeneratedCodeAccessedViaReflection
DataFlow.CompilerGeneratedCodeDataflow
DataFlow.CompilerGeneratedTypes
Expand All @@ -113,7 +114,6 @@ DataFlow.ExtensionMembersDataFlow
DataFlow.FeatureCheckDataFlow
DataFlow.FeatureGuardAttributeDataFlow
DataFlow.FieldDataFlow
DataFlow.FieldKeyword
DataFlow.GenericParameterDataFlow
DataFlow.GenericParameterDataFlowMarking
DataFlow.GenericParameterWarningLocation
Expand All @@ -124,7 +124,6 @@ DataFlow.MemberTypes
DataFlow.MemberTypesAllOnCopyAssembly
DataFlow.MethodParametersDataFlow
DataFlow.ModifierDataFlow
DataFlow.NullableAnnotations
DataFlow.ObjectGetTypeDataflow
DataFlow.PropertyDataFlow
DataFlow.RuntimeAsyncMethods
Expand Down Expand Up @@ -316,7 +315,6 @@ LinkAttributes.LinkAttributeErrorCases
LinkAttributes.LinkerAttributeRemoval
LinkAttributes.LinkerAttributeRemovalAndPreserveAssembly
LinkAttributes.LinkerAttributeRemovalConditional
LinkAttributes.OverrideAttributeRemoval
LinkAttributes.TypedArguments
LinkAttributes.TypedArgumentsErrors
LinkXml.CanPreserveAnExportedType
Expand Down Expand Up @@ -369,33 +367,22 @@ References.MissingReferenceInUsedCodePath
References.ReferenceWithEntryPoint
Reflection.ActivatorCreateInstance
Reflection.AssemblyImportedViaReflectionWithDerivedType
Reflection.ConstructorsUsedViaReflection
Reflection.ConstructorUsedViaReflection
Reflection.CoreLibMessages
Reflection.EventHanderTypeGetInvokeMethod
Reflection.EventsUsedViaReflection
Reflection.ExpressionCallString
Reflection.ExpressionFieldString
Reflection.ExpressionPropertyString
Reflection.FieldsUsedViaReflection
Reflection.IsAssignableFrom
Reflection.MembersUsedViaReflection
Reflection.MemberUsedViaReflection
Reflection.MethodsUsedViaReflection
Reflection.MethodUsedViaReflection
Reflection.NestedTypesUsedViaReflection
Reflection.NestedTypeUsedViaReflection
Reflection.ObjectGetType
Reflection.ObjectGetTypeLibraryMode
Reflection.ParametersUsedViaReflection
Reflection.PropertiesUsedViaReflection
Reflection.PropertyUsedViaReflection
Reflection.RunClassConstructor
Reflection.RuntimeReflectionExtensionsCalls
Reflection.TypeDelegator
Reflection.TypeHierarchyLibraryModeSuppressions
Reflection.TypeHierarchyReflectionWarnings
Reflection.TypeHierarchySuppressions
Reflection.TypeMap
Reflection.TypeMapEntryAssembly
Reflection.TypeUsedViaReflection
Expand Down Expand Up @@ -458,8 +445,6 @@ Symbols.ReferenceWithPortablePdbCopyActionAndSymbolLinkingEnabled
TestFramework.VerifyAttributesInAssemblyWorks
TestFramework.VerifyAttributesInAssemblyWorksWithStrings
TestFramework.VerifyLocalsAreChanged
TopLevelStatements.BasicDataFlow
TopLevelStatements.InvalidAnnotations
TypeForwarding.AttributeArgumentForwarded
TypeForwarding.AttributeArgumentForwardedWithCopyAction
TypeForwarding.AttributeEnumArgumentForwardedCopyUsedWithSweptForwarder
Expand Down
Loading