Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 VA 2385: pragma warning breaks class parsing?

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Uniwares Posted - Sep 07 2020 : 05:51:53 AM
I have a few C# classes here with the following:
namespace Q7.Production
{
#pragma warning disable CA1001 // Types that own disposable fields should be disposable
    public sealed class ProductionHandler
#pragma warning restore CA1001 // This class is never disposed
    {
    }


As a result, all classes with this pragma are not being parsed by VA, Alt+M is empty, VA Outline shows:



As compared to CodeMaids view of the same class:




PS: I wont even talk about the coloring of the #pragma in the VA Outline window...
4   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Sep 07 2020 : 2:02:23 PM
I have the same problem here now, apologies for the delay. I figured out what I was doing wrong, I was testing this with an existing namespace already in the file, so instead of getting a basically empty list, I got a fairly full list, due to the other namespace, but basically nothing from the sample code you provided. It "only" takes out the class, not any following class or namespace, but when you only have one class in the file, it takes out the entire file:

case=142844
Uniwares Posted - Sep 07 2020 : 09:26:19 AM
Following a stripped down class that shows this error on my IDE. Alt+M should show the ctor and the Instance property. When I enable "Show Regions" in the Alt+M, they dont show up.


using System;
using System.Diagnostics;

namespace Q7.Samples
{
	/// <summary>
	///	This class manages users and access<br/>
	/// </summary>
#pragma warning disable CA1001 // Types that own disposable fields should be disposable

	public sealed class StrippedDownSample
#pragma warning restore CA1001 // This class is never disposed
	{
		#region Private Fields

		private static readonly Lazy<StrippedDownSample> lazy = new Lazy<StrippedDownSample>(() => new StrippedDownSample());

		#endregion Private Fields

		#region Private Constructors

		/// <summary>
		/// Private Constructor => use SecurityHandler.Instance to access
		/// </summary>
		private StrippedDownSample()
		{
		}

		#endregion Private Constructors

		#region Public Properties

		/// <summary>
		/// Returns the one and only instance of this object (singleton)
		/// </summary>
		public static StrippedDownSample Instance
		{
			[DebuggerStepThrough]
			get
			{
				return lazy.Value;
			}
		}

		#endregion Public Properties
	}
}








Uniwares Posted - Sep 07 2020 : 09:21:23 AM
Updated to 2389m continues with the same behaviour. Only change is in coloring of the pragma in the VA outline view.

This method of using the pragma comes from the Code Analyzer directly, so VA should support it (besides it being legal C# syntax)
feline Posted - Sep 07 2020 : 08:57:33 AM
Can you please try updating to VA 2389, which is now available here:

https://support.wholetomato.com/default.asp?W404#2389

simply adding this example to the top of one of my C# code files does not show the problem at all. The problem makes some sense, since VA is probably not expecting a # line between the class name and the opening { bracket, but even then, I would not expect this to stop the entire file from being shown. But so far no problem in either VA Outline or the Alt-M list for me.

© 2019 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000