|
|
BINGO!
And I didn't even get out of the first sentence.
|
|
|
|
|
|
Gack!!!
I was lucky in the first half of my career. I worked at a privately owned company run by an engineer. There was none of this type of BS. It had some of it's own problems but never none of this type of crap.
|
|
|
|
|
A total snoozer that will be ancient history in 2 weeks. But they’re getting paid huge amounts because some CxO bought their pitch. And we can’t get an upgraded server because there’s no budget for it.
|
|
|
|
|
So, if a pastry chef were to give you a colonic, is that considered innuendo?
Ciao !
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Cute, but pizza chef might work better.
|
|
|
|
|
I no desecrate-ah the glory of-a the pizza !
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Quote: a colonic She may have fed me a stupid pill again, but WTF is that?
Get me coffee and no one gets hurt!
|
|
|
|
|
Cp-Coder wrote: She may have fed me a stupid pill again
Yeah - she must have. Google agrees.
Who knows what the final outcome will be?[^]
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Here's my error
System.ArgumentNullException: 'Value cannot be null.
Parameter name: values'
... for this mess:
Columns.AddRange(obj.GetType().GetGenericArguments().FirstOrDefault()?.GetProperties().Where(p =>
{
return p.GetCustomAttributes(true).OfType<BrowsableAttribute>().FirstOrDefault()?.Browsable ?? DefaultBrowsableState;
}).Select(p =>
{
return new ColumnHeader()
{
Name = p.Name,
Text = p.GetCustomAttributes(true).OfType<DisplayNameAttribute>().FirstOrDefault()?.DisplayName ?? p.Name
};
}).ToArray());
The thing is, I know what it's trying to do, and the code makes sense to me even though I didn't write it. The LINQ isn't really that bad here. But the error message is just awful. I don't even know where to begin. Time to hand roll the same statement LINQless so I can debug it.
So consider this my part 2 in why LINQ is for the birds.
Real programmers use butterflies
|
|
|
|
|
I love LINQ. Developers have been using it for years now, with great success.
Sorry you have found another technology that you hate.
|
|
|
|
|
There's a pretty large gulf between not liking something and hating it.
If I don't like it, it just means I'll avoid using it, and sometimes complain about it.
If I hated it I'd probably actively seek to destroy it somehow, and that would be a fight with Microsoft I'd rather not invest in, especially since it's one I couldn't win.
Real programmers use butterflies
|
|
|
|
|
Every technology has its place, For simple filtering and selection Linq is quite fine.
But for this I would have used other techniques. (Admittedly mixed with linq)
|
|
|
|
|
Looks like it's trying to compete with compiler error messages involving C++ templates.
|
|
|
|
|
There are so many things not to like about C++ templates but I love them anyway. It's shameful, my inconsistencies in this regard. I suppose it's because LINQ wasn't part of C# since the beginning, I didn't consider C# and LINQ to be irrevocably linked (pardon the pun) the way I do with C++ and templates. It's part of the language, not a "bag on the side". That probably contributes to the difference in attitude I have toward each. But also a little inconsistency never really bothered me that much.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: But also a little inconsistency never really bothered me that much.
A foolish consistency is the hobgoblin of small minds.
-- Emerson
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Reminds me of people who don't use paragraphs.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
My crystal ball says your object's type doesn't contain any generic arguments, so you're passing null to AddRange .
var genericArguments = obj.GetType().GetGenericArguments();
if (genericArguments.Length != 0)
{
Columns.AddRange(genericArguments[0].GetProperties()
.Where(p => p.GetCustomAttributes(true).OfType<BrowsableAttribute>().FirstOrDefault()?.Browsable ?? DefaultBrowsableState)
.Select(p => new ColumnHeader
{
Name = p.Name,
Text = p.GetCustomAttributes(true).OfType<DisplayNameAttribute>().FirstOrDefault()?.DisplayName ?? p.Name,
});
} Throw in a custom extension method to simplify it slightly:
public static class AttributeExtensions
{
public static TAttribute GetCustomAttribute<TAttribute>(this ICustomAttributeProvider value, bool inherit = true)
where TAttribute : Attribute
{
if (value is null) throw new ArgumentNullException(nameof(value));
object[] attributes = value.GetCustomAttributes(typeof(TAttribute), inherit);
return attributes.Length == 0 ? null : (TAttribute)attributes[0];
}
}
var genericArguments = obj.GetType().GetGenericArguments();
if (genericArguments.Length != 0)
{
Columns.AddRange(genericArguments[0].GetProperties()
.Where(p => p.GetCustomAttribute<BrowsableAttribute>()?.Browsable ?? DefaultBrowsableState)
.Select(p => new ColumnHeader
{
Name = p.Name,
Text = p.GetCustomAttribute<DisplayNameAttribute>()?.DisplayName ?? p.Name,
});
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yeah I sorted it out. It was being applied to an instance of the wrong class. The code that's using it is ridiculously complicated, and something small was out of place.
This error was the end result. I still think it's suitable for the purposes of this rant.
Such is life sometimes. I'm working with lots of Other People's Code(TM) at the moment. It's not so much that any one of them is particularly bad, so much as gluing together so many different paradigms is well.. as you can expect. But the main complication of it all is making it designable so my client can open it up in visual studio and tweak it, because he likes to be able to. He can code some, but I'd prefer he keep his mitts off what i write. I can deal with him using the designer. It works for both of us because he's afraid of my code anyway, and that way he doesn't have to bug me for little changes, but sometimes the code to make it all go properly is nasty.
Real programmers use butterflies
|
|
|
|
|
All this complaining about LINQ and AddRange, a non-LINQ function, was the problem?
Nothing a good old stack trace couldn't have pointed out by the way
|
|
|
|
|
Which functions takes a "values" parameter? I would guess it's Columns.AddRange() ?
If so, then my first guess would be that the problem is with obj.GetType().GetGenericArguments() not having any items (length == 0).
I guess this is one of the reasons we try to write readable code... so we also get more specific error messages. This one-liner nonsense is bad for everyone.
|
|
|
|
|
The underlying issue is that this garbage is a "one-liner". One-liners are darn near impossible to debug. LinQ invites, and even encourages this crap into the code.
|
|
|
|
|
As does SQL. If a given statement works, just keep piling on until it doesn't, then post it in Q&A.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
And Linq combined with extension methods makes one-liners even more fun! I write them frequently!
|
|
|
|