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
Error BC30512 Option Strict On tripped in VS2015 and not in VS2013 #13314
Comments
Thanks for reporting this. We will take a look at this issue. |
@isburns Please provide the library that defines the types used. Thanks. |
@isburns I am closing this issue due to the lack of the data required for investigation. Please reactivate it once you are ready to provide access to the library. Thanks. |
Apologies for not responding sooner, I was out of the office for a few days when you asked for the library. I am trying to attach it now, but I get the message "Unfortunately, we don't support that file type. Try again with a PNG, GIF, JPG, DOCX, PPTX, XLSX, TXT, PDF, or ZIP." The DLL is in a ZIP file when I try to upload it. Shea |
You can try changing extension before zipping it up, using external file sharing service, or disassembling the library with ILDASM into a TXT file and attaching that in a ZIP. An original DLL would be preferred, though. |
Renaming the file before zipping it did not work, however renaming the zip file itself did. You will need to download the file, then change the .txt to .zip. |
@isburns Thanks. It looks like ESRI.ArcGIS.Geometry.dll has another dependency, ESRI.ArcGIS.System. Could you please attach all the dependencies required to compile the following code without errors about missing type definitions?
|
Sorry I missed that, I confirmed that it is the only other required reference. I renamed the extension of the zip file again, so you'll need to change it back from .txt to .zip once you download it. |
With Option Strict On, Roslyn reports the following errors:
Native compiler compiles the code without the errors. |
This is an intentional behavior change, a bug fix in Roslyn. All three types (ESRI.ArcGIS.Geometry.Polygon, ESRI.ArcGIS.Geometry.Path and ESRI.ArcGIS.Geometry.Triangles) are interfaces and none of them implement ESRI.ArcGIS.Geometry.IGeometry (directly or indirectly). If I remember correctly, VS2013 compiler was inconsistent in deciding what should be the result type of "Newing" an interface, in some cases it was a CoClass, in other cases it was an interface (I believe one of the scenarios like that was a scenario with an object initializer). It was decided that the correct behavior of the compiler is to always use the interface as the result type of "Newing" an interface. Given that, Roslyn behavior is By Design. @AnthonyDGreen, @jaredpar Please, let me know if you disagree with the resolution. |
Version Used:
Visual Studio Community 2015, Version 10.0.25424.00 Update 3 (doesn't work)
Visual Studio Professional 2013, Version 10.0.40629.00 Update 5 (works)
Steps to Reproduce:
Using the ArcObjects SDK for the Microsoft .NET Framework for ArcGIS 10.4 and targeting 4.5.2 of the .NET Framework, the following line of code results in error BC30512 Option Strict On Disallows implicit conversions from 'IPolygon' to 'IGeometry'.
Dim bufferedPolygon As ESRI.ArcGIS.Geometry.IGeometry = New ESRI.ArcGIS.Geometry.Polygon
Polygon is the class interface of the COM coclass of the same name. This behavior is inconsistently, and perhaps improperly enforced, because other class interfaces in the same library both trigger and do not trigger the error. All examples given are widening conversions where the class interface/coclass instantiated inherits from the Geometry abstract class. Additionally, none of the examples given trip errors in Visual Studio 2013 targeting .NET Framework 4.5.2 with the same ArcObjects SDK for ArcGIS 10.4.
This also triggers the error.
Dim aPath As ESRI.ArcGIS.Geometry.IGeometry = New ESRI.ArcGIS.Geometry.Path
Dim tri As ESRI.ArcGIS.Geometry.IGeometry = New ESRI.ArcGIS.Geometry.Triangles
This does not.
Dim aSphere As ESRI.ArcGIS.Geometry.IGeometry = New ESRI.ArcGIS.Geometry.Sphere
Dim pt As ESRI.ArcGIS.Geometry.IGeometry = New ESRI.ArcGIS.Geometry.Point
Dim aRay As ESRI.ArcGIS.Geometry.IGeometry = New ESRI.ArcGIS.Geometry.Ray
Viewing the OMDs (see attached), a pattern initially appeared where the instantiating class interfaces (Point, Ray, Sphere) that are first descendents of the Geometry abstract parent class do not trigger the error and instantiating class interfaces (Polygon, Path) that inherit from another abstract class which inherits from the Geometry abstract parent class do trigger the error. However, Triangles is a first descendent of Geometry and it fails, so the lineage does not tell the whole story. The COM to .NET type conversion of the ArcObjects documentation is relevant: Using ArcObjects (COM-Based in .NET (ArcObjects .NET 10.4 SDK).
GeometryObjectModel.pdf
The text was updated successfully, but these errors were encountered: