© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
24 replies
swagrid

❔ Roslyn analyzer test project can't compile `where T : unmanaged` type constraint

I've made a roslyn analyzer for some marshaling stuff. In my test project I try to analyze this source code:
    struct FooTest<T> where T : unmanaged
    {
        T good;
    }
    struct FooTest<T> where T : unmanaged
    {
        T good;
    }

but when I try to compile this code I get:
error CS0518: Predefined type 'System.Runtime.CompilerServices.IsUnmanagedAttribute' is not defined or imported

Why the error? I know there are similar issues with
IsExternalInit
IsExternalInit
, but my test project runs on .net 6.0 and the test code above is compiled with the latest C# version. AFAIK, the
unmanaged
unmanaged
constrain came with C# 7.3 / .net core 2.0.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Rider - Custom Roslyn Analyzer
C#CC# / help
3mo ago
❔ Roslyn analyzer rules extraction
C#CC# / help
3y ago
Rider Roslyn Analyzer Not Working (Partially)
C#CC# / help
9mo ago
✅ Roslyn analyzer: System.Guid only has _dummyPrimitive field?
C#CC# / help
3y ago