Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Fix marking types inside custom attributes. Fixes #47064 - #7

Merged
spouliot merged 1 commit into
dotnet:masterfrom
spouliot:custom-attributes-arrays
Jan 13, 2017
Merged

spouliot merged 1 commit into
dotnet:masterfrom
spouliot:custom-attributes-arrays

Conversation

@spouliot

@spouliot spouliot commented Dec 9, 2016

Copy link
Copy Markdown
Contributor

The existing code for marking custom attributes was only marking the type
and the lowest element type, i.e. marking (1) would also mark (3) but
would miss (2).

  1. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[][]))]
  2. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[]))]
  3. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>))]

That's generally not an issue since the type is marked (elsewhere).
However, in the case of custom attributes, we need to update the Scope
to what was resolved (and that was missed).

That lack of updated Scope means that a PCL assembly would still keep
references to System.Runtime, which is something that the linker is
eliminating (causing a TypeLoadException at runtime)

reference:

The existing code for marking custom attributes was only marking the type
and the lowest element type, i.e. marking (1) would also mark (3) but
would miss (2).

1. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[][]))]
2. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[]))]
3. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>))]

That's generally not an issue since the type is marked (elsewhere).
However, in the case of custom attributes, we need to update the Scope
to what was resolved (and that was missed).

That lack of updated Scope means that a PCL assembly would still keep
references to System.Runtime, which is something that the linker is
eliminating (causing a TypeLoadException at runtime)

reference:
* https://bugzilla.xamarin.com/show_bug.cgi?id=47064
@dnfclas

dnfclas commented Dec 9, 2016

Copy link
Copy Markdown

Hi @spouliot, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

spouliot added a commit to spouliot/mono that referenced this pull request Dec 9, 2016
The existing code for marking custom attributes was only marking the type
and the lowest element type, i.e. marking (1) would also mark (3) but
would miss (2).

1. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[][]))]
2. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[]))]
3. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>))]

That's generally not an issue since the type is marked (elsewhere).
However, in the case of custom attributes, we need to update the Scope
to what was resolved (and that was missed).

That lack of updated Scope means that a PCL assembly would still keep
references to System.Runtime, which is something that the linker is
eliminating (causing a TypeLoadException at runtime)

reference:
* https://bugzilla.xamarin.com/show_bug.cgi?id=47064

Note: The linker is not in mono/master and there's a PR in the new
linker repo for the same dotnet/linker#7
@sbomer

sbomer commented Dec 9, 2016

Copy link
Copy Markdown
Member

Don't mind the failing build yet - the ci is still being set up. :)

@sbomer

sbomer commented Dec 9, 2016

Copy link
Copy Markdown
Member

test ci please

spouliot added a commit to mono/mono that referenced this pull request Dec 16, 2016
The existing code for marking custom attributes was only marking the type
and the lowest element type, i.e. marking (1) would also mark (3) but
would miss (2).

1. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[][]))]
2. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[]))]
3. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>))]

That's generally not an issue since the type is marked (elsewhere).
However, in the case of custom attributes, we need to update the Scope
to what was resolved (and that was missed).

That lack of updated Scope means that a PCL assembly would still keep
references to System.Runtime, which is something that the linker is
eliminating (causing a TypeLoadException at runtime)

reference:
* https://bugzilla.xamarin.com/show_bug.cgi?id=47064

Note: The linker is not in mono/master and there's a PR in the new
linker repo for the same dotnet/linker#7
@erozenfeld

Copy link
Copy Markdown
Contributor

LGTM

joshpeterson pushed a commit to Unity-Technologies/mono that referenced this pull request Jan 6, 2017
The existing code for marking custom attributes was only marking the type
and the lowest element type, i.e. marking (1) would also mark (3) but
would miss (2).

1. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[][]))]
2. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>[]))]
3. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.Generic.Dictionary<string, object>))]

That's generally not an issue since the type is marked (elsewhere).
However, in the case of custom attributes, we need to update the Scope
to what was resolved (and that was missed).

That lack of updated Scope means that a PCL assembly would still keep
references to System.Runtime, which is something that the linker is
eliminating (causing a TypeLoadException at runtime)

reference:
* https://bugzilla.xamarin.com/show_bug.cgi?id=47064

Note: The linker is not in mono/master and there's a PR in the new
linker repo for the same dotnet/linker#7
@erozenfeld

Copy link
Copy Markdown
Contributor

@spouliot Would you like to merge this PR?

@erozenfeld

Copy link
Copy Markdown
Contributor

@dotnet-bot retest please

@spouliot
spouliot merged commit c85ac36 into dotnet:master Jan 13, 2017
@spouliot
spouliot deleted the custom-attributes-arrays branch January 13, 2017 02:34
@spouliot

Copy link
Copy Markdown
Contributor Author

Sorry :) we're not yet using this repo so it fell under my radar

jtschuster added a commit to jtschuster/linker that referenced this pull request Jan 19, 2022
parent ea177be
author Jackson Schuster <[email protected]> 1642552698 -0800
committer Jackson Schuster <[email protected]> 1642552698 -0800

Add Function to parse xml and return a list of injected attributes

Finalize schema so all test xml is valid

Add restrictions on some attributes and change uses of "nothing" to
"none"

Remove schema reference in generated file expectation

Initial Schema work

# This is the commit message dotnet#6:

Add restrictions on some attributes and change uses of "nothing" to
"none"

# This is the commit message dotnet#7:

Adds a more restrictive schema for LinkAttributes and updates paths for
linux

# This is the commit message dotnet#9:

Update docs to use 'none' instead of 'nothing'

# This is the commit message dotnet#10:

remove schema from xml expectation file
tkapin pushed a commit to tkapin/runtime that referenced this pull request Jan 31, 2023
…rays

Fix marking types inside custom attributes. Fixes dotnet/linker#47064

Commit migrated from dotnet/linker@c85ac36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants