C
C#3y ago
Jayy

dotnet6 project failing on static abstracts with preview features set to true

C:\Users\Kellen James\source\Repos\ClemBot\ClemBot.Api\ClemBot.Api.Core\Features\Tags\Edit.cs(51,49): error CS8920: The
interface 'IQueryResult<Edit.TagDto>' cannot be used as type argument. Static member 'IQueryResult<Edit.TagDto>.Succes
s(Edit.TagDto?)' does not have a most specific implementation in the interface. [C:\Users\Kellen James\source\Repos\Cle
mBot\ClemBot.Api\ClemBot.Api.Core\ClemBot.Api.Core.csproj]
C:\Users\Kellen James\source\Repos\ClemBot\ClemBot.Api\ClemBot.Api.Core\Features\Tags\SetCustomTagPrefix.cs(31,48): err
or CS8920: The interface 'IQueryResult<ulong>' cannot be used as type argument. Static member 'IQueryResult<ulong>.Succ
ess(ulong)' does not have a most specific implementation in the interface. [C:\Users\Kellen James\source\Repos\ClemBot\
ClemBot.Api\ClemBot.Api.Core\ClemBot.Api.Core.csproj]
4 Warning(s)
261 Error(s)
C:\Users\Kellen James\source\Repos\ClemBot\ClemBot.Api\ClemBot.Api.Core\Features\Tags\Edit.cs(51,49): error CS8920: The
interface 'IQueryResult<Edit.TagDto>' cannot be used as type argument. Static member 'IQueryResult<Edit.TagDto>.Succes
s(Edit.TagDto?)' does not have a most specific implementation in the interface. [C:\Users\Kellen James\source\Repos\Cle
mBot\ClemBot.Api\ClemBot.Api.Core\ClemBot.Api.Core.csproj]
C:\Users\Kellen James\source\Repos\ClemBot\ClemBot.Api\ClemBot.Api.Core\Features\Tags\SetCustomTagPrefix.cs(31,48): err
or CS8920: The interface 'IQueryResult<ulong>' cannot be used as type argument. Static member 'IQueryResult<ulong>.Succ
ess(ulong)' does not have a most specific implementation in the interface. [C:\Users\Kellen James\source\Repos\ClemBot\
ClemBot.Api\ClemBot.Api.Core\ClemBot.Api.Core.csproj]
4 Warning(s)
261 Error(s)
I am seeing this error attempting to use static abstracts in a .net 6 project
12 Replies
Jayy
JayyOP3y ago
this code works on other peoples machines fine, its on a 6.0.400 install of dotnet cc @tannergooding maybe? Static abstracts are sorta your wheel house
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<LangVersion>preview</LangVersion>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<LangVersion>preview</LangVersion>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
</PropertyGroup>
csproj
tannergooding
tannergooding3y ago
.net 6 has many limitations as not all runtime support is ghere Also going camping until Wednesday, so little internet
Jayy
JayyOP3y ago
ahh ok, have fun ohh wow ok, so i upgraded my sdk from 6.0.1 -> 6.0.4 and it started failing for me fascinating this feels like a bug
333fred
333fred3y ago
Show code, but likely not a bug
333fred
333fred3y ago
GitHub
Disallow interfaces with static virtual members as type arguments ·...
This proposal attempts to address a type hole that has been pointed out a number of times with static virtual members, e.g. here. Static virtual members (Proposal: static-abstracts-in-interfaces.md...
Jayy
JayyOP3y ago
did this ship 5 days ago as part of 6.0.8 of the runtime?
333fred
333fred3y ago
Wouldn't surprise me
Jayy
JayyOP3y ago
thats fantastic lol -_- and code is this
public interface IQueryResult<T> : IResult<T, QueryStatus>
{
static abstract IQueryResult<T> Success(T? val);
static abstract IQueryResult<T> Invalid(T? val);
static abstract IQueryResult<T> NotFound();
static abstract IQueryResult<T> Conflict();
static abstract IQueryResult<T> Forbidden();
}
public interface IQueryResult<T> : IResult<T, QueryStatus>
{
static abstract IQueryResult<T> Success(T? val);
static abstract IQueryResult<T> Invalid(T? val);
static abstract IQueryResult<T> NotFound();
static abstract IQueryResult<T> Conflict();
static abstract IQueryResult<T> Forbidden();
}
Patrick
Patrick3y ago
for a moment i thought you had lied to us all about your name
Jayy
JayyOP3y ago
public class Handler(ClemBotContext _context) : IRequestHandler<Command, IQueryResult<Model>>
{
}
public class Handler(ClemBotContext _context) : IRequestHandler<Command, IQueryResult<Model>>
{
}
Jayy
JayyOP3y ago
ree
Jayy
JayyOP3y ago
this is quite unfortunate i am going to have to rewrite... everything for this and i cant write a conversion cuz its an interface ree

Did you find this page helpful?