Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REFL037 warn if all symbols are visible and not reference assembly. #197

Open
JohanLarsson opened this issue Nov 16, 2018 · 2 comments
Open

Comments

@JohanLarsson
Copy link
Collaborator

  1. In next Roslyn version Compilation.MetadataImportOptions will be public so we can check.
  2. We also need to check for [ReferenceAssembly] if present we can perhaps try to resolve from the GAC and use refelection.

http://source.roslyn.io/#Microsoft.CodeAnalysis/MetadataReader/MetadataImportOptions.cs,05f2bcc4af4b3736
https://github.com/dotnet/roslyn/blob/master/docs/features/refout.md#definition-of-ref-assemblies

@jnm2
Copy link
Collaborator

jnm2 commented Nov 16, 2018

GAC makes builds inherently unreliable. Imagine using hosted CI in which a new machine picks up your work each time.

Pointing back to #161 (comment):

  • Is there any chance that this is an assembly reference that does not end up in build output?
    High chance it will run against a different version with a different set of private members, e.g. the BCL. ❌ Cannot prove nonexistence.

Going to the GAC to go around this is even worse IMO.

@jnm2
Copy link
Collaborator

jnm2 commented Nov 16, 2018

If I'm targeting net472 and doing GetType on some type that will never exist in net472, the situation clearly shows that I'm expecting the same assembly to sometimes run on net48 and that I expect to handle the situation in which the type doesn't exist.

A stronger example of this is NUnitLite's .NET Standard build which uses reflection to detect whether it is on .NET Core and if so, drive AssemblyLoadContext using reflection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants