Questions tagged [nullability]
27 questions
0
votes
0 answers
Warning [CS8622] caused by NotNullWhenAttribute
Is this a bug in the compiler, or am I missing something?
public delegate bool Lambda([NotNullWhen(true)] out TState? state);
class Foo
{
void Bar()
{
var lambda = new Lambda(
(out string? state) =>
{
…

Ed Pavlov
- 2,353
- 2
- 19
- 25
0
votes
1 answer
Stop nullability warnings from entity framework queries that include nullable navigation properties
Consider an entity framework core model with the following two entities:
public class RiskAssessment {
public string Title { get; set; } = string.Empty;
public Guid? ActivityID { get; set; }
public Activity? Activity { get; set; }
}
public…

Kevin O'Donovan
- 1,620
- 1
- 13
- 24
0
votes
2 answers
What is the difference between LiveData() and LiveData()
I am new to LiveData thing in general and I am having a hard time understanding the difference between LiveData() and LiveData(). I used them interchangeably and nothing seams to break. I know that LiveData.getValue() is marked with…

Khalida Aliyeva
- 26
- 3
- 12
0
votes
1 answer
Is there a way to indicate to C# nullability analysis that an instance variable will never be null after a certain method runs?
I've got a class with an instance var that can be null, and that class has a method that initializes that var. Broadly simplified, it looks a bit like this
#nullable enable
class SomeClass
{
private Foo? someObject;
private void…

newclearwinter
- 1,073
- 1
- 8
- 7
0
votes
1 answer
Make the Intellisense nullability warning conditional, similar to Dictionary.TryGetValue(...)
In Visual Studio, Intellisense is smart enough to know that the 'out' variable value in Dictionary.TryGetValue(string key, out string value) is not null if the method returns true:
I'm trying to emulate this with the following…

user3163495
- 2,425
- 2
- 26
- 43
0
votes
1 answer
Can't assign non-nullable type to a nullable one
error: The argument type 'Future
- >' can't be assigned to the parameter type 'Future
- >?'.
Is this Dart Analysis or me? The project still compiles.
Upd. Added code…

Selqet
- 1
- 1
0
votes
1 answer
Why does the compiler allow instantiation of generic class both with a nullable and non-nullable generic parameter?
I have a project in ASP.NET Core 6.
I have the enable setting in the project.
I have the following class:
public class ResponseResult
{
public T? Result{ get; set; }
}
I can instantiate the class with a nullable or…

MiBuena
- 451
- 3
- 22
0
votes
2 answers
Difficulty defining nullability constraints
I have an extension function called TryGetValueAs which basically combines TryGetValue with a cast. The problem is that I keep getting nullability warnings and I can't seem to get it right.
I have the following code:
using…

Rick de Water
- 2,388
- 3
- 19
- 37
0
votes
1 answer
How to Determine Nullability (NRT) of Generic Type Parameter?
For example, I might have a method with the following signature:
public async Task GetPersonUri()
Using reflection I would like to determine if the type parameter of Task is a nullable reference type. In the case, the answer would be…

Dejan
- 9,150
- 8
- 69
- 117
0
votes
4 answers
how to make thie non-pointer type property nullable in objc
hi iam learning IOS development & for learning porpoises
i want to know how to make this property nullable in objc
(this Four @property)
@property (nonatomic) BOOL Hood;
@property (nonatomic) BOOL smartclean;
@property (nonatomic) t_ShirtSize…

Saad
- 17
- 4
-1
votes
1 answer
Vector of 'nullable' HashMaps in rust
I am finding extremely difficult to deal with vectors of HashMaps in rust. I want to use vectors of HashMaps as an implementation of a sparse matrix container according to constraints that I, hopefully, will be able to explain below.
Most…

Redirectk
- 160
- 9
-1
votes
1 answer
How to implement method accepting ICollection and ICollection
Given the following method:
public static void DisposeItems(this ICollection collection)
where T : class, IDisposable
{
foreach (var item in collection)
{
item?.Dispose();
}
if (!collection.IsReadOnly)
{
…

Manfred Brands
- 3
- 3