Quantcast
Channel: User DaveShaw - Stack Overflow
Browsing latest articles
Browse All 43 View Live

Comment by DaveShaw on ASP.NET Core MSB4018 in new project

Do you have a nuget.config file with D:\VS\VS SDK \NuGetPackages in it? The error suggests that path doesn't exist.

View Article



Comment by DaveShaw on Can auto-implemented properties be less efficient (.NET)?

Correct, but if you had an auto property, get and setcost the same. Typically, people use methods for expensive operations. For example, set wouldn't save to a database, you would use a Save() method...

View Article

Comment by DaveShaw on Functional programming and decoupling

Not an answer, but there's a lot written on blog.ploeh.dk about functional architectures.

View Article

Comment by DaveShaw on Haskell occurring error regarding show instance

One example: (Or (Var x) (And (Var y) (Var z))) - and there will be many more. I think you will need a recursive fold to format this data structure as it itself is recursive

View Article

Comment by DaveShaw on Why form dropdown items are sorted alphabetically?

There's a whole topic of DB design here. If this is just a small list, you could try a heap table (no clustered index), or add an identity column and make that the clustered index. It depends on the...

View Article


Comment by DaveShaw on Azure Pipeline dotnet not creating release build

Have a look at the logs, maybe turn on detailed/diagnostic logging and see if anything jumps out.

View Article

Comment by DaveShaw on How to display records in SQL Server that have same...

I've had a go at tidying up the question (I removed the image and formatted the tables), but it isn't clear what logic you are wanting to apply to this. Are you looking for rows where there is only a...

View Article

Comment by DaveShaw on Is there a .NET 6 equivalent System.Console assembly

I've never had to manually install that - not sure if it is something dotnet includes behinds the scenes. Also, it looks to be compatible with .net6:...

View Article


Comment by DaveShaw on .net 5.0 resolve dependencies from a separate folder

Won't client and server not live on different machines and not be able to share the same folder?

View Article


Comment by DaveShaw on Warning when nullable int is involved in an arithmetic...

A helpful blog posts (maybe)

View Article

Comment by DaveShaw on Why does Guid.ToByteArray in C# "rechange" the byte...

Source is here, but I can't explain: referencesource.microsoft.com/#mscorlib/system/guid.cs,892

View Article

Comment by DaveShaw on I can access static methods, but not instantiable ones

Always read error messages, (and then search for them if you don't understand them) :)

View Article

Comment by DaveShaw on Why doesn't this C# generic delegate assign?

"All you need to do in order to make your code compile is constrain T to be a value type"... Did you mean reference type?

View Article


Comment by DaveShaw on How do I set the headers in azure subscriptions API?

No idea how to do it, but could you manually create one then do a GET? - I imagine part of consumerInputs object

View Article

Comment by DaveShaw on How do I set the headers in azure subscriptions API?

Maybe give an example/or a source for the quoted documentation?

View Article


Answer by DaveShaw for Accessing a control in a main form from a child form

You could keep looking around in the debugger - Quick Watch will help - and eventually you will find the properties of this on the childForm instance that allow you to go back "up" to the main for and...

View Article

Answer by DaveShaw for C# Field Naming Guidelines?

_camelCase for fields is common from what I've seen (it's what we use at our place and Microsoft prefer for the .NET Runtime).My personal justification for using this standard is that is is easier to...

View Article


Answer by DaveShaw for removing a specific string from a label c#

You can use String.Replace.label1.Text = label.Text.Replace("world", String.Empty);+= on a string is a shortcut for s = s +"something".I've never seen a programming language where you can remove the...

View Article

Answer by DaveShaw for The type ''a list' is not compatible with the type...

The problem is the extra [] after your first div.In the following: div [] [ "hello" |> str ] you have 2 lists. The first is an empty list of properties, the second is a list of child elements - with...

View Article

Answer by DaveShaw for giraffe routef async function

I don't have all the types imported to make the whole thing compile, but I think you need to remove the >=> from the delete:DELETE >=> choose [ (routef "/people/%s" deletePerson)]And the...

View Article

Answer by DaveShaw for Getting all indices of elements matching criteria in F#

I'm not sure if there is a built in function on the List module for this, but it easy enough to use the other functions to do it.let l = [ 1; 2; 3; 4; 5 ]let idxs = l |> List.indexed |>...

View Article


Answer by DaveShaw for F# Data: How to get all navigation links from a website?

Assuming you want the links from https://scrapethissite.com/ then you would need to look at the HTML of those navigation links and find a pattern that would return them.Looking at the source of the...

View Article


Answer by DaveShaw for F# (F sharp) unzip function explained

Firstly, this is a recursive function - the rec keyword is a giveawy :).These can be quite hard to get you head around, but are quite common in functional programming.I'll assume you are OK with most...

View Article

Answer by DaveShaw for Interpolated strings in F#

When this was asked, F# didn't have string interpolation.Today though, there is an RFC for it that is merged in in F# 5.0 allowing string interpolation in F#.The error was because the $ symbol is...

View Article

Answer by DaveShaw for Foreach cannot operate on a 'method group' while...

I think .Values is a method, not a property.You should add parenthesis to invoke it.foreach (var val in parsedthothTest.Values()){}

View Article


Why does assigning a Task then awaiting it allow to run in parallel [duplicate]

I've was playing around with async and I've happened across some behaviour I've not noticed before, if this is a duplicate please let me know, but my google-fu has failed me, mostly because I can't...

View Article

Answer by DaveShaw for Is it possible to remove the full-paths from .NET...

C# compiler (csc) has a compiler switch -deterministicF# compiler (fsc) appears to have a switch --deterministic+From looking at the DotNet SDK repo it appears there are 2 properties for project...

View Article

Answer by DaveShaw for Generic function to check if value exists within DbSet

Func<T, bool> - Sounds like the right approach to what you want.bool IsFieldValueUnique<T>(Func<T, bool> checkFunction){ var alreadyExists = DbSet<T>.Any(checkFunction); return...

View Article

Answer by DaveShaw for Need Converting Help C# to F#

Something like this should do the trick:let getEnumDescription value = let fi = value.GetType().GetField(value.ToString()) let attributes = fi.GetCustomAttributes(typedefof<DescriptionAttribute>,...

View Article



Answer by DaveShaw for Deserialise JSON to Dictionary

A pure .NET Core example if you are only after something simple:let json = """{"some_ key" : "some_value"}"""let data = System.Text.Json.JsonDocument.Parse(json) .RootElement .EnumerateObject() |>...

View Article

Answer by DaveShaw for F# async lambda interop with C# async model

Without knowing too much about the Pulimu API's I'd guess that Apply is expecting a Task<T>.You can convert from F# async to Task using Async.StartAsTask like so:let registryInfo =...

View Article

Answer by DaveShaw for HttpClient ReadAsByteArrayAsync vs ReadAsStreamAsync

Looking at the source the ByteArray method will read the entire stream into a new byte[] copy for you.// The returned array is exposed out of the library, so use ToArray rather// than TryGetBuffer in...

View Article

Answer by DaveShaw for How to create CTE which uses another CTE as the data...

You can chain 2 (or more) CTE's together.For examplewith ObjectsWithA as( select * from sys.objects where name like '%A%'),ObjectsWithALessThan100 as( select * from ObjectsWithA where object_id <...

View Article


Image may be NSFW.
Clik here to view.

Answer by DaveShaw for Visual Studio (Community): How do I change the...

Right click on the Project in the Solution Explorer Window and select "Set as Startup Project"

View Article

Answer by DaveShaw for possible null reference return c# linq

The method returns a Task<Pie>.The return ... has SingleOrDefaultAsync(...) at the end which means if it cannot find an item with a matching id it will return default(Pie) which will be null.You...

View Article

Answer by DaveShaw for How to force a WinForms control to fill up...

You can't really Dock inside a flow layout panel, it makes no sense.A flow layout panel is used to contain a collection of controls that flow together (left to right, top to bottom), having one control...

View Article


Answer by DaveShaw for Object reference not set to an instance of an object,...

It is most likely .InnerException that will be null. Not all exceptions have one.You should only need to log ex.ToString() and the InnerException and StackTrace will be logged as part of that...

View Article


Answer by DaveShaw for Assigning a value to an instance of a class in C#...

You can add an implicit (or expicit) operator to your class like so:public static implicit operator ComplexNumber(int i) => new ComplexNumber(i, 0);That will allow you do what you want.As you used 2...

View Article

Answer by DaveShaw for Checking for uninitialized DateTime properties?

You could change the DateTime to DateTime? then they can be null, which seems to be the most accurate representation of what you want (a date that can have no value).Then you...

View Article

Answer by DaveShaw for Convert IEnumerable to another IEnumerable C#

The long hand way is using LINQ's .Select extension method on IEnumerable<T> to project one the items from one collection into another:IEnumerable<CarEntity> carEntities =...

View Article

Answer by DaveShaw for Should I make a private method public just for testing?

You could test it as it is.Just create your own version of orderRepository.Here's an example of a very crude API, alter to your preference (or use Moq if you are that way inclined).// The Test//...

View Article


Image may be NSFW.
Clik here to view.

Answer by DaveShaw for Multiple "Value" queries in TFS 12.0

You can use In to search for any value in a delimited set. Separate values with the list separator that corresponds to the regional settings that are defined for your client computer. For example, you...

View Article
Browsing latest articles
Browse All 43 View Live




Latest Images