Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Scrub [ComVisible] attribution from CoreFX library sources #782

Merged
merged 1 commit into from
Feb 16, 2015

Conversation

stephentoub
Copy link
Member

Per #779, this PR scrubs [ComVisible] attribute from the CoreFX library sources.

@jkotas, one thing I'm unsure of: since [ComVisible(true)] is the default for desktop, and since some of these libraries (e.g. immutable collections, dataflow, etc.) can be used with the desktop, should we actually be applying [ComVisible(false)] to every assembly? Some of the assemblies already had this, and with the current commit I've removed those, but if they're needed I can put them back and make sure the other libraries have such attribution, too.

@@ -26,5 +26,4 @@
[assembly: NeutralResourcesLanguageAttribute("en-US")]

[assembly: CLSCompliant(true)]
[assembly: ComVisible(false)]
Copy link
Member

Choose a reason for hiding this comment

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

Note this is going to conflict with #771/#772 with the mirroring so please do not commit any changes to AssemblyInfo.cs files. If we need ComVisible(false) on everything we should include it in the generated _AssemblyInfo.cs file we are going to be including soon.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, Wes. Yes, I'll hold off on merging until the mirror is enabled. Sounds like we shouldn't need to add anything, but good to know we'll be able to do it in a single place if necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the PR after rebasing from #772.

@jkotas
Copy link
Member

jkotas commented Feb 15, 2015

should we actually be applying [ComVisible(false)] to every assembly?

I think it should be fine to strip the ComVisible(false) assembly attributes in corefx.

ComVisible(false) disables the types in the assembly from being exposed as COM interfaces - e.g. it prevents somebody from running the tlbexp tool on the assembly and then use the types from C++ via COM. ComVisible(false) assembly attribute is important for desktop in-box assemblies where we go out of our way to avoid compatibility issues by explicitly disallowing fragile features that apps may take (intentional or accidental) dependency on. I do not think this concern applies for corefx.

cc @yizhang82 Please speak up if you disagree.

@stephentoub
Copy link
Member Author

Thanks, Jan.

@yizhang82
Copy link
Contributor

I consider adding ComVisible(false) to every single assembly as good practice, regardless what platform it is. This would make sure we don't accidentally expose them as COM objects both statically and at runtime, and also avoid generating unnecessary COM interop marshalling code statically (such as in .NET native). Putting ComVisible(false) in a AssemblyInfo.cs that gets automatically included to every project sounds very reasonable if this is easy to do.

@jkotas
Copy link
Member

jkotas commented Feb 16, 2015

It used to be a good practice for desktop libraries. The default template for desktop class libraries has the assembly ComVisible(false) attribute.

However, none of the modern VS templates (e.g. portable libraries, Windows Store, ...) have the assembly ComVisible(false) attribute. I assume that it was removed as unnecessary cruft. It means that majority of the modern 3rd party code does not have the assemblu ComVisible(false), and so you cannot really depend on it to solve problems like avoid generating unnecessary COM interop marshalling code...

@richlander
Copy link
Member

Even if that weren't true, there's also the new world of Linux, Mac and other OSes to consider. Imagine that the entrance of .NET Core off of Windows truly explodes (that'd be awesome, right!). I don't think we can impose a Windows-ism (with either polarity of setting), particularly for a relatively soft reason.

@weshaggard weshaggard added the enhancement Product code improvement that does NOT require public API changes/additions label Feb 16, 2015
@davkean
Copy link
Member

davkean commented Feb 16, 2015

This has no impact on the contract. We already strip ComVisible from them.

@davkean
Copy link
Member

davkean commented Feb 16, 2015

@jkotas The reason that Store/PLIB templates don't have ComVisible(false) is because the ComVisibleAttribute didn't exist in the surface area at the time those things were originally written.

@stephentoub
Copy link
Member Author

I've opened dotnet/buildtools#77 to track automatically adding [ComVisible(false)] to each assembly if we decide it's the right thing to do. In the meantime, I'll go ahead with this scrub.

stephentoub added a commit that referenced this pull request Feb 16, 2015
Scrub [ComVisible] attribution from CoreFX library sources
@stephentoub stephentoub merged commit c36ce30 into dotnet:master Feb 16, 2015
@stephentoub stephentoub deleted the remove_comvisible branch February 16, 2015 18:52
stephentoub added a commit to stephentoub/corefx that referenced this pull request Jul 15, 2015
In dotnet#782 we scrubbed all of the [ComVisible] attributes from corefx, but more have snuck in since then.  Doing another pass.
stephentoub added a commit to stephentoub/corefx that referenced this pull request Jul 15, 2015
In dotnet#782 we scrubbed all of the [ComVisible] attributes from corefx, but more have snuck in since then.  Doing another pass.
@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
In dotnet/corefx#782 we scrubbed all of the [ComVisible] attributes from corefx, but more have snuck in since then.  Doing another pass.


Commit migrated from dotnet/corefx@db5a5ef
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants