HBoskugelS
(Holger Boskugel)
June 20, 2025, 1:30pm
1
SonarQube Server: Community Build v25.5.0.107428
No information available about configuration, not maintained by us.
We use a cascaded extension in the following way:
public static class Extensions
{
public static Object[] GetAttributes<T>(this ICustomAttributeProvider customAttributeProvider,
Boolean inherit = false)
where T : Attribute
{
return customAttributeProvider.GetCustomAttributes(typeof(T),
inherit)
}
public static Object[] GetAttributes<T>(this Object @object,
Boolean inherit = false)
where T : Attribute
{
return @object.GetType().GetCustomAttributes<T>(inherit);
}
}
The extension for type Object
gets reported as issue. It doesn’t take care about the more specific extension of type ICustomAttributeProvider
when using the same parametrized method after GetType
.
Hello @HBoskugelS ,
I was not able to reproduce the issue.
In your code snippet, I don’t see the potential infinite loop.
Could you give more details or refine your snippet?
Thank you,
HBoskugelS
(Holger Boskugel)
July 1, 2025, 7:54pm
5
Don’t know why it’s not happen at your test. I have this issue:
Here original code:
Colin
(Colin)
July 1, 2025, 7:56pm
6
@HBoskugelS Please don’t post screenshots of code. Text-based code samples please.
HBoskugelS
(Holger Boskugel)
July 1, 2025, 7:59pm
7
public static String GetCodeVersion(this Object obj_Object_p)
{
obj_Object_p.TestThrowArgumentNullException("obj_Object_p");
return obj_Object_p.GetType().GetCodeVersion();
}
public static String GetCodeVersion(this ICustomAttributeProvider customAttributeProvider)
{
customAttributeProvider.TestThrowArgumentNullException(nameof(customAttributeProvider));
return customAttributeProvider.GetCustomAttribute<CodeVersionAttribute>()?.Value.ToString();
}
public static T GetCustomAttribute<T>(this ICustomAttributeProvider customAttributeProvider,
Boolean inherit = false)
where T : Attribute
{
// Implicit parameter check
T[] attributes = GetCustomAttributes<T>(customAttributeProvider,
inherit);
if(attributes.Length == 1)
{
return attributes[0];
}
return null;
}
public static T[] GetCustomAttributes<T>(this ICustomAttributeProvider customAttributeProvider,
bool inherit = false)
where T : Attribute
{
return customAttributeProvider.GetCustomAttributes(typeof(T),
inherit)
.Cast<T[]>();
}
[CodeVersion("2.1")]
[ComVisible(false)]
[AttributeUsage(AttributeTargets.All)]
public class CodeVersionAttribute :
Attribute,
ICodeVersion
{
public CodeVersionAttribute(String str_Version_p)
{
this.Value = new Version(str_Version_p);
}
public CodeVersionAttribute(Int32 int_Major_p,
Int32 int_Minor_p,
Int32 int_Build_p = 0,
Int32 int_Revision_p = 0)
{
this.Value = new Version(int_Major_p,
int_Minor_p,
int_Build_p,
int_Revision_p);
}
public Version Value { get; protected set; }
public String CodeVersion
{
get
{
return this.GetType().GetCodeVersion();
}
}
}
[CodeVersion("1.0")]
[Guid("BC4AAD10-AF01-43CE-86A8-5584B4683A12")]
public interface ICodeVersion
{
String CodeVersion { get; }
}
you selected the wrong Holger
Hello @HBoskugelS ,
Unfortunately, I am still not able to reproduce the issue.
Could you share with me the verbose output of the analysis?
I will need the logs of the begin and end step as well as the build logs.
Share the Scanner for .NET verbose logs
Add /d:"sonar.verbose=true"
to the…
SonarScanner.MSBuild.exe
or dotnet sonarscanner
begin command to get more detailed logs
For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
“SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties
argument if you are using Azure DevOps
The important logs are in the END
step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)
Share the msbuild detailed logs
MsBuild.exe /t:Rebuild /v:d
or
dotnet build -v:d
Thank you,
HBoskugelS
(Holger Boskugel)
July 2, 2025, 11:15am
11
This will need some time. Where are the log files stored? We use the Scanner for MSBuild with Framework 4.7.2.
You can redirect the output of the scanner to a file.
All the logs are written to the standard output.
Scanner for MSBuild is the old name of Scanner for .NET, they basically work the same whatever flavor (.NET or .NET Framework) you are using.
Take your time, if you need to send the logs privately let me know!