Questions tagged [non-nullable]

232 questions
2
votes
0 answers

C# 8's non-nullable references fields in structs

Is this a hole in C# 8's NNR checks? public struct V { private readonly double[] data; public V(int size) => data = new double[size]; public int Length => data.Length; } var v = new V(); Console.WriteLine(v.Length); I thought the…
2
votes
1 answer

How do I get a Non-Nullable T in C# to use it in a function?

got an error in this code. private void Save(string file) where T : struct, IPixel { Image image = Image.LoadPixelData( _image.Data, _image.Width, _image.Height); image.Save(file); …
2
votes
1 answer

Non-nullable default return null warning

In C#8 we can now enable nullables, which means that reference types by default are considered not null by the compiler unless explicitly declared as nullable. Yet, it seems the compiler still throws a warning when trying to return a default generic…
HotN
  • 4,216
  • 3
  • 40
  • 51
2
votes
0 answers

Enable the nnbd experiment in pana and on pub.dev

I published a package and get a devastating health result from the pub server with the error message: This requires the 'non-nullable' experiment to be enabled. Actually, that's what I did! I did enable the nnbd experiment in my…
user3464741
2
votes
1 answer

C# 8.0 Non Nullable Types compatible Classic NetFramework (4.X)

I am starting a new Project with Blazor Asp.NET Core 3.1 and all the cool new shiny fancy stuff. But for one interface to a client I still need a solution that supports WCF and thereby supports net framework 4.8. So if I set my api Project (so far…
Michael P
  • 241
  • 3
  • 8
2
votes
2 answers

kotlin - remove nullability from class properties

I have a class with some nullable properties data class RequestModel( val description: String? ) and a validation function fun validate(model: RequestModel): RequestModel{ if(model.description == null) throw…
Fartab
  • 4,725
  • 2
  • 26
  • 39
2
votes
1 answer

Testing a non-null parameter in Kotlin

new to Kotlin here! I just switched some Java testing code into Kotlin and a specific case of null codes is bugging me for the moment. I am trying to test (in a Kotlin @Test code segment) whether this java function raises the right…
2
votes
1 answer

react-native-camera error when compiling android - cannot find symbol class NonNull

package.js ... "react": "16.8.3", "react-native": "0.59.5", "react-native-camera": "git+https://git@github.com/react-native-community/react-native-camera.git" ... settings.gradle include ':app' include…
2
votes
2 answers

Non-nullable ID with spring-data-mongodb in Kotlin

Is there any chance to make the @Id property non-nullable for Mongo-related entities in Kotlin? Referring to this post there seems to be a solution for SQL by setting the ID initially to 0. However, that seems like a hack, and seems to work only…
Jan B.
  • 6,030
  • 5
  • 32
  • 53
2
votes
1 answer

Why does Eclipse JDT Null-Checking respect Apache Commons Validate

I use @NonNull-Checking with Eclipse-JDT and was very pleased to see that it understands and respects the use of Apache Commons Validate. Which means in code: Validate.notNull(someInput); @NonNull String a = someInput; Without the first line the…
groovedigga
  • 233
  • 3
  • 13
2
votes
1 answer

Kotlin - How to prevent null gets into Map object during jackson Json deserialization?

Firstly let me past some runnable code to help you get the issue I want to solve: (maven dependency to include if you want to run this example code) com.fasterxml.jackson.module
Fuyang Liu
  • 1,496
  • 13
  • 26
2
votes
3 answers

Non-Nullable Virtual Propery in Entity Framework Code-First Model

I need to generate two database tables with a one-to-many relationship from my site's Entity Framework models; Blog and Tag. A blog can have many tags but a tag can only belong to one blog. My Blog model consists of an ID property (Guid) as a…
Jonny
  • 29
  • 3
2
votes
1 answer

How do I use Java collections of non-nullable elements from Kotlin?

Using the interop automatisms Kotlin has for nullability, a method like this gets the proper signature in Kotlin: @NonNull public String foo(@NonNull String bar) { return "bar"; } Now lift the principle to collections (or other generics, I…
Raphael
  • 9,779
  • 5
  • 63
  • 94
2
votes
1 answer

NSError** 'Potential null dereference.....'

Giving the following example: - (BOOL) doSomething: (NSError**) pError { *pError = [NSError ....]; } Analyzer will return the following error: Potential null dereference. According to coding standards in 'Creating and Returning NSError…
Kyle
  • 17,317
  • 32
  • 140
  • 246
2
votes
1 answer

Can't avoid Intellij throwing IllegalArgumentException with @NotNull

Is there anything else I can do when unchecking "Add runtime assertions for not-null annotated methods and parameters" doesn't work? It keeps throwing IllegalArgumentException. I've also tried disabling the Inspections for @NotNull/@Nullable…
garci560
  • 2,993
  • 4
  • 25
  • 34