Marko Apfel - Afghanistan/Belgium/Germany

Management, Architecture, Programming, QA, Coach, GIS, EAI

  Home  |   Contact  |   Syndication    |   Login
  187 Posts | 2 Stories | 201 Comments | 4 Trackbacks

News



Twitter | LinkedIn | Xing

Article Categories

Archives

Post Categories

Image Galleries

BizTalk

C#

Enterprise Library

SAP

SQL Server

Technologie

Addins in ArcGIS Desktop 10 uses tool generated code of the Config.esriaddinx file.

Have a look at the properties you will see this tool – named ArcGISAddInHostGenerator.

This tool creates some classes in the depending file “Config.Designer.cs”. Unfortunately these classes are not marked with the GeneratedCode-attribute.

This ends with warnings like:

CA1811 : Microsoft.Performance : 'ArcMap.DockableWindowManager.get()' appears to have no upstream public or protected callers.

CA1811 : Microsoft.Performance : 'ArcMap.Document.get()' appears to have no upstream public or protected callers.

CA1811 : Microsoft.Performance : 'ArcMap.Events.get()' appears to have no upstream public or protected callers.

CA1811 : Microsoft.Performance : 'ArcMap.ThisApplication.get()' appears to have no upstream public or protected callers.

 

CA1812 : Microsoft.Performance : 'ThisAddIn' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static methods, consider adding a private constructor to prevent the compiler from generating a default constructor.

CA1812 : Microsoft.Performance : 'ThisAddIn.IDs' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static methods, consider adding a private constructor to prevent the compiler from generating a default constructor.

One way to eliminate these warnings is to set the GeneratedCode-attribute manually at the affected classes:

[GeneratedCode("ArcGISAddInHostGenerator", "10.0.0.0")]
internal static class ArcMap
[GeneratedCode("ArcGISAddInHostGenerator", "10.0.0.0")]
internal class ThisAddIn

But if the file is generated again these variant is not ideal because you must edit the classes again.

Another way is the suppress in the AssemblyInfo.cs file.

Then you must specify SuppressMessage-attributes for each warning at assembly-level. In my case the above stated warnings are suppressed with the following lines:

[assembly:
	SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member",
		Target = "EsriDE.Samples.ContentFinder.AgdAdapter.ArcMap.get_DockableWindowManager():ESRI.ArcGIS.Framework.IDockableWindowManager")]
[assembly:
	SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member",
		Target = "EsriDE.Samples.ContentFinder.AgdAdapter.ArcMap.get_Document():ESRI.ArcGIS.ArcMapUI.IMxDocument")]
[assembly:
	SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member",
		Target = "EsriDE.Samples.ContentFinder.AgdAdapter.ArcMap.get_Events():ESRI.ArcGIS.ArcMapUI.IDocumentEvents_Event")]
[assembly:
	SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member",
		Target = "EsriDE.Samples.ContentFinder.AgdAdapter.ArcMap.get_ThisApplication():ESRI.ArcGIS.ArcMapUI.IMxApplication")]
[assembly:
	SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Scope = "type",
		Target = "EsriDE.Samples.ContentFinder.AgdAdapter.ThisAddIn")]
[assembly:
	SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Scope = "type",
		Target = "EsriDE.Samples.ContentFinder.AgdAdapter.ThisAddIn+IDs")]
posted on Wednesday, May 11, 2011 1:35 PM