CsprojToVs2017
CsprojToVs2017 copied to clipboard
Work out how to deal with ComVisible and if it can be moved to csproj
It would be good if this could be cleared out or moved to the csproj. Below is a very typical example based on the default project created by Visual Studio. I think without ComVisible(false), the default in the compiler is true.
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("29644e8e-6ee0-4337-8658-c926dfa83f55")]
Yeah, ComVisible is still true by default in CPS I'm afraid. It's a known bad practice and even VS sets it to false by default in AssemblyInfo on project generation. I believe we must preserve default behavior (true), but make a diagnostic for that case.
At least
[assembly: Guid("29644e8e-6ee0-4337-8658-c926dfa83f55")]
could be dropped?
A related issue: https://github.com/Microsoft/msbuild/issues/2281
Perhaps after some time the following code will become available:
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.InteropServices.ComVisibleAttribute">
<_Parameter1>false</_Parameter1>
<_Treat_Parameter1AsLiteral>true</_Treat_Parameter1AsLiteral>
</AssemblyAttribute>
</ItemGroup>
@HavenDV ... I hope so. I'm still championing my proposed more succinct flavor of:
<ItemGroup>
<AssemblyAttribute
Include="System.Runtime.InteropServices.ComVisibleAttribute"
IsLiteral="true"
_Parameter1="false" />
</ItemGroup>
.. but I'll take a win however I can get it