-
Notifications
You must be signed in to change notification settings - Fork 382
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
Guidance or suggestions needed for when .proto files are generating classes #1141
Comments
Have you tried with "type filtering"? Do you know the name of types right? |
How does that work for Visual Studio's Test Explorer? |
@MarcoRossignoli - these c# types are generated at compile time by protoc.exe from a .proto file. Sure I can guess but there wont be a pattern from project to project. |
@MarcoRossignoli the protoc maintainers are going to add |
@StingyJack They will not be skipped automatically, you have to include the attribute in the ExcludeByAttribute setting. Documentation on that setting: Example of how to set it with the VSTest integration: |
in the case of the proto generated classes, we are getting by with writing a small "code coverage patch" file that has additional parts for all the namespace YourProtosNamesapce
{
using System.Diagnostics.CodeAnalysis;
[ExcludeFromCodeCoverage]
public static partial class ExampleDataProtoService { }
[ExcludeFromCodeCoverage]
public static partial class ExampleDataStackReflection { }
//etc...
} ... which is not hard to create but still takes time to make. Are there any reasons why [GeneratedCode] is not automatically skipped as part of the analysis?
|
I think it is because there is no Adding |
@petli - once the GrpcTools version that marks the generated code as |
Also here is a link that was shared with me to what the Roslyn compiler thinks is generated code. dotnet/docs#24657 (comment) |
I have projects that have .proto files in them and that are using the Grpc.Tools nuget package. That package will "compile" the contents of the proto file into c# classes whenever the proto is changed and saved or when the project is built.
This generated code does not carry the
[ExcludedFromCodeCoverage]
attribute, nor is it in a.g.cs
file, but it does have an//<AutoGenerated>
on the first line, and all of the code is inside of a#region Designer generated code
region. Coverlet is currently including this code as "not covered", but as its code that is generated by a 3rd party tool, I think it should be excluded from the coverage evaluation.What should or can I do here to avoid having this code be included in the coverage evaluation?
EDIT For completeness, the things that are commonly used to denote code that is generated and that should be excluded are
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
[GeneratedCode]
.g.cs
, .g.vb
, or similar.designer.cs
, .designer.vb
, or similar#region Windows Form Designer generated code
protobuf compiler uses none of these conventions and instead uses
#region Designer generated code
// <AutoGenerated>
An example proto file contents
generates a code file that starts like this
Also linking grpc/grpc#25950
The text was updated successfully, but these errors were encountered: