SteveGilham / altcover

Cross-platform coverage gathering and processing tool set for dotnet/.Net Framework and Mono
MIT License
498 stars 18 forks source link

Consideration of closing brackets in the coverage #170

Closed tilak-nanavati-opshub closed 1 year ago

tilak-nanavati-opshub commented 1 year ago

Currently, in our production environment, we have observed that particularly the closing braces '}' are also highlighted for coverage details.

As per our understanding the closing braces '}' should be non-executable, so we would like to confirm whether AltCover considers such symbols (closing braces '}' ) as executable and present the line hit details against that.

We are adding a screenshot for the same to bring more clarity.

image

Coverage XML (Cobertura report) image

Note: We read the Cobertura coverage report generated by AltCover to determine which lines were covered or not.

SteveGilham commented 1 year ago

The process is more along the lines of "the debug information says that this is significant code ( = you can set a break-point on it), so I'll record it as such", being entirely agnostic as to what that represents in the original source.

In this particular case, the end of a catch clause, the closing } will typically correspond to a Leave opcode, a special-purpose branch instruction indicating the flow of control out of the try/catch construct, plus possible Nop opcodes for alignment purposes. This is, however, entirely compiler dependent : the following code --

        public async Task<bool> CheckFolderExists(string folder)
        {
            try
            {
                using var response = await client.PostAsync(String.Empty, null);

                return await IsResponseSuccessfulAsync(response);
            }
            catch (Exception e)
            {
                return false;
            }
        }

has no sequence point corresponding to the last line but one.

tilak-nanavati-opshub commented 1 year ago

Hi Steve,

Thank you for the quick response. We understood the point made.

SteveGilham commented 1 year ago

Release v8.4.840 provides the option to ignore such trivial sequence points (--trivia. /p:AltCoverTrivia=true, or equivalent)

tilak-nanavati-opshub commented 1 year ago

Hi Steve,

Thank you for this update.

This piece of information would turn out to be very useful.

Thanks again.