"Option Strict On disallows implicit conversions" inconsistent enforcement

447 Views Asked by At
  • configuration 1: building ESRI add-ins for ArcMap 10.4 using Visual Studio 2015 targeting the .NET 4.5.2 framework
  • configuration 2: building ESRI add-ins for ArcMap 10.3 using Visual Studio 2013 targeting the .NET 3.5 framework
  • configuration 3: building ESRI add-ins for ArcMap 10.4 using Visual Studio 2013 targeting the .NET 4.5.2 framework

I'm trying to understand why the Option Strict On enforcement in VB.NET projects does not raise error BC30512 in two projects and it does in another. Here is an an example line of code that triggers the error using configuration 1 but does not trigger the error with configuration 2 or 3.

Dim bufferedPolygon As ESRI.ArcGIS.Geometry.IGeometry = New ESRI.ArcGIS.Geometry.Polygon

Additionally, if I instantiate the managed class instead of the coclass, the error is not triggered in either configuration (see following line):

Dim bufferedPolygon As ESRI.ArcGIS.Geometry.IGeometry = New ESRI.ArcGIS.Geometry.PolygonClass

The different versions of ArcMap dictate which version of the framework is targeted. For additional background, the COM to .NET Type Conversion of the ArcObjects documentation is relevant: Using ArcObjects (COM-based) in .NET (ArcObjects .NET 10.4 SDK)

Why is the error triggered in configuration 1 and not in configuration 2 or 3? And why isn't the error triggered in configuration 1 when instantiated with the managed class instead of the coclass?

Link to an issue submitted at the dotnet/roslyn github repository. https://github.com/dotnet/roslyn/issues/13314

Thanks Shea

1

There are 1 best solutions below

0
isburns On

At this time, it appears (as Hans Passant suggested in a comment on the original post) that this is indeed a bug with the Roslyn compiler in Visual Studio 2015. I opened an issue at the dotnet / roslyn GitHub repository, and it has been labeled a bug and assigned to a team member. The status of this could change as the issue is investigated.

The link to the issue and additional troubleshooting information is https://github.com/dotnet/roslyn/issues/13314