Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Expose Assembly.Location via public contract#3861

Merged
nguerrera merged 1 commit into
dotnet:masterfrom
nguerrera:assembly-location
Oct 16, 2015
Merged

Expose Assembly.Location via public contract#3861
nguerrera merged 1 commit into
dotnet:masterfrom
nguerrera:assembly-location

Conversation

@nguerrera
Copy link
Copy Markdown
Contributor

After some discussion, it seems we should just expose Assembly.Location after all. It already does not guarantee a path (string.Empty for load from stream/byte[], NotSupportedException for dynamic assembly). On .NET Native, we can simply return String.Empty.

This has been requested many times over: #2221, dotnet/coreclr#1367 (+ lots of requests offline).

Note that there are still scenarios not covered such as getting source path in DNX when compiled on the fly, but I think we can continue to discuss that separately. I believe those scenarios are better served by a separate API rather than an Assembly.Location override.

cc @weshaggard @jkotas

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This + the System.Runtime.Loader dependency just caused these tests to not be runnable on .NET Native. We should consider splitting these out so we can still use these reflection tests on more of our platforms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pragmatically, all 3 tests are actually dependent on not being run on .NET Native at the moment. The .NET Native test will just be Assert.NotNull(ThisAssembly().Location); Assert.Empty(ThisAssembly.Location()). However, we don't currently share enough infrastructure to express that directly here in corefx repo.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All I want to be careful about is that when we start running these test on .NET Native that we don't loose all the reflection tests because of these new tests. If we think that might happen perhaps we should factor some of these out into another test project.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. Split out the tests in to a separate project.

@nguerrera nguerrera force-pushed the assembly-location branch 4 times, most recently from d18c877 to df68985 Compare October 14, 2015 21:52
@jkotas
Copy link
Copy Markdown
Member

jkotas commented Oct 14, 2015

Does it also need to be flipped to public in https://github.com/dotnet/coreclr/blob/master/src/mscorlib/model.xml ?

@nguerrera
Copy link
Copy Markdown
Contributor Author

@jkotas Hmm, I imagined it was already there as tests are passing and I see the property and its public getter in ildasm of coreclr mscorlib. I am now trying to understand what is making that happen without the entry where I'd expect it to be in model.xml...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. We should probably update other .sln fils to include the ref projects as well.

@davidfowl
Copy link
Copy Markdown
Member

golf clap 👏

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somehow build TinyAssembly.dll as part of the build process rather than checking in the binary?

@stephentoub
Copy link
Copy Markdown
Member

One question, otherwise LGTM.

@nguerrera nguerrera added the api-needs-work API needs work before it is approved, it is NOT ready for implementation label Oct 15, 2015
@nguerrera
Copy link
Copy Markdown
Contributor Author

@stephentoub I'm also using it in #3896 to get a known-guid -- i.e. depending on it not changing. (C#'s new deterministic feature would help with that eventually.)

The file is ~1.5KB uncompressed and ~500B compressed. The contents are deliberately as minimal as possible and I don't think it will change much if at all.

S.R.Loader also has source for a small assembly, but also checks in the dll to embed the resource. (That can probably be fixed by using ProjectReference with OutputItemType=EmbeddedResource, mind you.) We're embedding as resource in both cases to get around corerun putting everything in sight on the TPA list.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you want to use a package reference once these changes get published? If so please file a tracking issue.

@weshaggard
Copy link
Copy Markdown
Member

LGTM

@nguerrera
Copy link
Copy Markdown
Contributor Author

I submitted dotnet/coreclr#1783 to be explicit in the model file.

@terrajobst terrajobst added the api-approved API was approved in API review, it can be implemented label Oct 16, 2015
@terrajobst
Copy link
Copy Markdown

@weshaggard, @KrzysztofCwalina and myself just took a look. Approved 👍

@nguerrera
Copy link
Copy Markdown
Contributor Author

Added missing copyright headers and caught up to master in rebase. No other changes since LGTMs. I will merge when tests pass.

@stephentoub
Copy link
Copy Markdown
Member

nguerrera added a commit that referenced this pull request Oct 16, 2015
Expose Assembly.Location via public contract
@nguerrera nguerrera merged commit 126241e into dotnet:master Oct 16, 2015
@nguerrera nguerrera deleted the assembly-location branch October 16, 2015 20:43
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Expose Assembly.Location via public contract

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

Labels

api-approved API was approved in API review, it can be implemented api-needs-work API needs work before it is approved, it is NOT ready for implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants