|
I see demons, but, not squiggles My impaired eyes are giving out for today, but, I note the apparent absence of 'show squiggles' in Tools/Options/C#/Advanced ... while /...C/C+ still has it.
Will look again, tomorrow.
thanks, Bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
Yes, that's what the warning is there for: to make sure you are doing what you intended, not accidentally hiding the original.
You don't get any exception because it is legal: it's a compile time problem only (and because it's a warning, it assumes the new for you).
Try going to your project properties, "Build" tab, and selecting "Treat warnings as error" to "All" - that should cause a compiler problem with that code.
My default new project includes that setting!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Try going to your project properties, "Build" tab, and selecting "Treat warnings as error" to "All"
::::::::: :::::::: :::::::: :::: :::: :::
:+: :+: :+: :+: :+: :+: +:+:+: :+:+:+ :+:
+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+:+ +:+ +:+
+#++:++#+ +#+ +:+ +#+ +:+ +#+ +:+ +#+ +#+
+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
#+# #+# #+# #+# #+# #+# #+# #+#
######### ######## ######## ### ### ###
😂🎉
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
|
|
|
|
|
I run with it all the time - the only time it gets annoying is when I forget to add an XML comment to a public item.
Every now and then, it picks up a "whoopsie" that I would have had to scratch my head over when it failed testing ... and that makes it all worthwhile.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yep, if you do it from the start, should not be an issue, but to apply it to existing code would be painful if there are a number of existing warnings.
Personally, I kill warnings as I go. I tend to write code quickly, then tighten it up once I'm happy with the execution. Allows flexibility where and when needed. Commits must be warning-free.
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
|
|
|
|
|
That's why "Treat errors" is so valuable: it won't let you continue unless you fix 'em!
I.e. I can't get lazy and procrastinate
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
many CS*** warnings are trivial, and disatracing. the issue here is how to break on errors at build-time, and you have nailed that !
you do have the ability to name CS*** you want blocked by entering them one by one in the Build facility.
i keep thinking one of the several updates of VS/64 did alter/reset my basic default project settings.
thanks, Bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
So THEHORROR=VISUALSTUDIO (-> tldr)?
Since I upgraded from VS2010 to the glitzy VS2022 (64-bit) I've never been more imprressed by a Microsoft corporation product paying attenciaonen to beautiful code intepretation and the ease with which it is now possible to throw gathered VS6.0 16-bit internet snippets at a compiler and get something to deliver the white bones of an executable that'll run away on it's own on Windows 10.
Horror, no ... honorable been-there-'doin-that-now, yes.
|
|
|
|
|
Yep. The more I use it, the more impressed I get with autocomplete as well. Intelligent assistance rather than dumb templating ... nice.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Same here; I really cannot understand people who complain about Visual Studio. I guess like "the young", they have no experience of life without technology that does everything for them - well almost everything.
|
|
|
|
|
Growing up with decks of cards, then paper tape, then real time Z80 assembler with a debugger you had to write yourself gives you an appreciation of how much easier it all is these days, I guess.
And most of 'em don't use the truly excellent debugger they are given for free, or even know it exists.
When I think back to C dev for Z80: Brief editor, IAR compiler / linker (with home written assembler where needed), EPROM programmer, screwdriver, run, swear, back to Brief ... and today I get compiler errors while I type the code along with suggested code that actually helps. We've come a long way.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: I use it
Well, I twitch spasmodically like sugarboy here ... but it sounds like you get the gist.
Op, there's Jimmy now. Tice. Gotta go.
|
|
|
|
|
You post a message congratulating yourself for using a later version of VS ... I use the latest version, also ... in a thread about a specific issue using VS.
You say nothing relevant to the issue and the context.
I seldom down-vote posts, but, you earned it.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
BillWoodruff wrote: why does C# let me get away with this
Doesn't java and C++ allow the same thing?
Certainly in terms of identifier resolution I wouldn't expect anything else.
|
|
|
|
|
thanks, interesting, I have not used Java or C++ IDE's.
i do struggle with both "loving" C#, and wishing it was even more build-time "strongly typed" ... PostSharp is an example of how strong-typing can be extended via Attributes... of course, PostSharp is rewriting IL code post compilation, and what it does is fiendlishly complex ... and using it is complex.
for me, seeing duplicate top level field/property/method/whatever names is a red flag: of course, i see no flags with reuse of names for local trivial reasons, like i/j/k for for-loops.
for me, using ReSharper (been using it many years) does provide some critical support.
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
From memory, I believe Java defaults to virtual methods - so unless you specifically tell it not to, the method in the derived class will be called. This increase the risk of breaking changes simply by updating a package you depend on. If the base happens to have added a method you also have (not that unheard of as you might have overwritten to add a feature the library author is also working on), then your code will execute to the surprise of both of you. In C# with default implementation both the base class and the derived class will execute the same code they did before the update if no other code change is made.
|
|
|
|
|
lmoelleb wrote: I believe Java defaults to virtual methods
Correct.
|
|
|
|
|
How to save ImageAnnotation in the sample Solution I downloads it.the sample have only add and delete.
Thanks
|
|
|
|
|
Ask the person who created the download. We cannot guess what you are referring to.
|
|
|
|
|
Don't post this under Quick Answers - if you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
gentle reminder: this forum is/was a language discussion forum; i ain't complaining, by saying that, that i think it being, now, more of a C# QA for grown-ups is a "bad thang"
the new .NET kid: [^] ... looks promising ... if (?) ...
you are remembering, as i do, the yogic contortions necessary for numeric Type conversions, the many different facilities from reflection, to 'ChangeType, etc.
and, the not=quite=-there weirdness necessary to try to constrain a generic parameter to a Numeric Type.
Scott Hanselman waxed eloquent on this in 2003: [^].
Okay ... the question is: have you tried/evaluated Math.Generics ?
And, what do you think ?
from the somewhat sidelined fossil, bill
«The mind is not a vessel to be filled but a fire to be kindled» Plutarch
|
|
|
|
|
I hadn't really used it yet (which may indicate something as well) but I briefly tried it just now, so keep in mind I don't really know my way around the API yet:
- Large repertoire of available operations, which applies to .NET 7 broadly, not only generic math. Nice operations such as rotates, popcount, leading zero count, are no longer hidden away in weird corners of the language (or worse: absent - as they used to be).
- Despite shift counts no longer needing to be
int , shifting by T is not allowed. So while working with T , shifting by constants is fine (since they'd be int ), but as soon as you want to shift by some value that comes out of a generic calculation.. well you still end up with some weird conversions. This also applies to the count parameter of rotates. This has anti-synergy with the return types of T.PopCount and T.TrailingZeroCount and so on, which return T . I definitely would want to write x >>> T.TrailingZeroCount(x) at some point, but no. - There is an explicit unsigned right shift, but
>> means "either signed or unsigned right shift depending on the type". What if I want an explicit signed right shift, even if T is an unsigned type? E: in non-generic code of course the answer is "just cast to the corresponding signed type, shift, then cast back". But then in generic code the question is, what type is that? See one of the next points for the problem with that. - There is no easy way to get the number of bits in
T . There are ways, sure, but I was hoping for T.BitSize or something like that. Do I really need to write T.PopCount(T.AllBitsSet) ? Bonus: the result of that is a T but you probably want an int . Or x.GetByteCount() * 8 perhaps? (why do I need an instance x to find the byte count?) - There seems to be no way to express certain constraints on types such as "given some signed type
TS , TU is the corresponding unsigned type of the same size". Well, I don't know how C# would do that. But I can do it in C++, and it would be useful. For example if I wanted to define a type-changing version of Abs , which takes a signed integer and returns an unsigned integer of the same size - as it is, I wouldn't be able to constrain the types to have the same size. As far as I know, anyway. - There are standard "low multiplications" that take two
T and return the low half of the product as a T . Elsewhere in .NET classes, there are functions such as Math.BigMul that return the full product. Generic T has a lot of fancy operations defined for it, but not BigMul (nor a hypothetical HighMul that only returns the upper half of the product).
Well it seems useful overall, but with some annoyances.
E: a sneaky advantage of generic math is that it lets you negate unsigned integers (ie find their additive inverse) with a plain old negation, no nonsense such as 0 - x . Progress! You still can't write -someUlong in non-generic code though.
modified 14-Jan-23 1:46am.
|
|
|
|
|
BillWoodruff wrote: And, what do you think ?
I think that if one has a lot of code that requires that one become familiar with that a lot then one of the following is true.
1. One is creating a mathematics library. Some advanced product, such as a matrix library
2. The code is wrong and someone is trying to be clever which will lead to increased maintenance costs.
|
|
|
|
|
I have a C# control application that communicates via USB (it shows up as a Com port in the Device Manager, but the electrical interface is USB, not RS232) with a development board with a microcontroller from ST Microelectronics (the driver I use is automatically installed by Windows 10 or Windows 11). Sometimes I need to debug and single-step the microcontroller and when I do, the C# application freezes for a long time and then usually eventually crashes when the Com port finally disappears and my Com connection is lost. Is there anything I can do to handle this a little more gracefully? It would be great if the Com port connection could simply get disconnected (instead of freezing the application) and the Com port disappears and then it could try to reconnect every second, in case the single-stepping has stopped and the microcontroller is running normally again. I'm programming in .NET 2.0 and I communicate using the System.IO.Ports.SerialPort class.
|
|
|
|
|
If you start "locking up" the device, then the app needs to be able to make async calls and perform the associated error handling. Otherwise, it "freezes".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|