|
Member 2652715 wrote: but do you mean Just showing that your analogy did not work.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
RyanDev wrote: And who would people go to instead of Microsoft?
You do realize there are other compilers on the market?
|
|
|
|
|
So, do you have an answer?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
MinGW-w64 (GCC) and Clang are two that are commonly used.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
RyanDev wrote: BryanFazekas wrote: Executables bloated with unnecessary code that does not help with the software's purpose Bloated seems like an overstatement. But OK.
The unstated thing is that, while MS claims they added this instrumentation to keep an eye on the performance of your applications, what is the performance and behavior of this telemetry logging functionality (and how will it change as they update their OS)? Can it cause app slowdowns? crashes? Fill your customer's disk? How does it change the attack surface of your app? If you don't know it's there, how will you be able to address any of this?
Worse, MS will feel free to change that code at any time, so you may wake up one day to find out that installed versions of your application are suddenly doing very bad things to your customers computers, and you didn't make any change at all to your code that could have caused it. You can deny all you want, but your customers are still going to blame you and your code.
And remember, Microsoft had no plans to tell you about this addition, they've been forced to remove it because their attempt to slip unwanted code into everybody's applications was discovered by a user and the community pushed back.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
patbob wrote: what is the performance and behavior of this telemetry logging functionality (and how will it change as they update their OS)? Can it cause app slowdowns? crashes? Fill your customer's disk? How does it change the attack surface of your app? If you don't know it's there, how will you be able to address any of this? But that's true about the entire .net stack as well as any 3rd party code you use.
patbob wrote: Microsoft had no plans to tell you about this addition, Again, so? Many of us have written code that gives us feedback so that we know how our software is running, or not.
It's their software, I don't see why we should be trying to dictate how it works.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
RyanDev wrote: But that's true about the entire .net stack as well as any 3rd party code you use.
True, it is. Its a risk we all take. However, while we don't know how the library is implemented, we do know what parts of it we're using because we're explicitly calling it. If there's issues with their library code, we can work around it.. somehow.
RyanDev wrote: It's their software, I don't see why we should be trying to dictate how it works.
I agree that we don't necessarily get a say in how their software works. It was unstated, but I didn't say they shouldn't collect their telemetry. I merely want to be informed about any changes they are making to my code that might affect it. After all, when my code breaks for my customers, they'll be holding my feet to the fire to get it fixed, not Microsoft's. It is far easier for me to fix code that I've written and can see, than some hidden addition that Microsoft inserts behind my back, and I don't even know is there until I get down and dirty with the generated assembly code.
I guess the real problem is that the compiler team has an implied "contract" with us, their users -- one clause of which is that they won't add any unnecessary garbage to our code. They violated that. They didn't tell us about that violation. They didn't give us any way to control that addition. In short, the compiler team violated the implied "contract".
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
patbob wrote: I merely want to be informed about any changes they are making to my code that might affect it. Serious? You want to read through release notes from a company that has 100's of software products and is releasing updates all the time? Not me.
patbob wrote: the compiler team violated the implied "contract". If you thought there was an implied contract that there would be no garbage in your code, then I have a bridge to sell you.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Well, I stopped using Visual Studio and C# several years ago (except on occasion when I deal with legacy software) for a variety of reasons, including their dodginess over privacy, but also for practical reasons (MS only really caters for selected audiences). I have no regrets about leaving C# behind. That's not to see it's all bad, it has some nice features, but too much proprietary crap comes with it.
|
|
|
|
|
Hm, glad I use g++ for my own applications. And as an embedded developer, I really don't have to use VS.
|
|
|
|
|
Wordpress site showing thousands of modified files every day - normal process for database website or not?
|
|
|
|
|
Think you need to take this and the other question to the Q&A section.....the lounge is not where this belongs!
|
|
|
|
|
You may have been the victim of a spam attack.
|
|
|
|
|
Bloody vikings!
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
I thought Vikings had better taste.
|
|
|
|
|
Depends upon how you cook them.
|
|
|
|
|
How is the express module both a function/method AND an object with properties?
|
|
|
|
|
Think you need to take this and the other question to the Q&A section.....the lounge is not where this belongs!
|
|
|
|
|
Wrong forum. You want this one[^]
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
Welcome to yet another example of real-world application of an existing .Net feature.
A few days ago, Mac Clifton made a Lounge post describing a little-known LINQ feature - the let clause. I'm sure several of you were wondering if you'd ever find a reason to use let in your own code. Well, I was writing some code today, and decided this would be a perfect example.
The code in question is a List extension method which matches a named property to the specified text, and returns the first item whose (named) property is equal to that specified text.
Without further ado, here's the method:
public static List<T> FindExact<T>(this List<T> list, string valuePropertyName, string text)
{
List<T> found = default(List<T>);
try
{
PropertyInfo info = typeof(T).GetProperty(valuePropertyName);
found = (from item in list
let value = (string)(info.GetValue(item, null))
where value == text
select item).ToList();
}
catch (Exception)
{
}
return found;
}
public static T FindFirstExact<T>(this List<T> list, string valuePropertyName, string text)
{
T found = default(T);
try
{
found = list.FindExact(valuePropertyName, text).FirstOrDefault();
}
catch (Exception)
{
}
return found;
}
public static T FindLastExact<T>(this List<T> list, string valuePropertyName, string text)
{
T found = default(T);
try
{
found = list.FindExact(valuePropertyName, text).LastOrDefault();
}
catch (Exception)
{
}
return found;
}
The first thing I do is set found to default(T) (the only valid way to set a value to null in a method that uses generic types).
Next, I get the property info for the named property.
Finally, I use LINQ to find the first item whose (named) property matches the specified text.
If an exception is thrown at any point in the method, a null result is returned.
(In hindsight, it might be better to return a list of matching items instead of the first one, but you get the point.)
EDIT =============================
I changed the code to be more flexible for my needs - I actually need to be able to find the first and/or last match, but don't care about anything between.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 9-Jun-16 13:04pm.
|
|
|
|
|
Awesome. Write it up as a tip with some examples.
If it's not broken, fix it until it is
|
|
|
|
|
So I just did this:
class Program
{<br />
static List<Person> people = new List<Person>();
static void Main(string[] args)
{
people.Add(new Person { Name = "Joan", Age = 102 });
people.Add(new Person { Name = "Pete", Age = 50 });
people.Add(new Person { Name = "Walter", Age = 65 });
people.Add(new Person { Name = "Joan", Age = 17 });
people.Add(new Person { Name = "Walter", Age = 25 });
var person1 = people.FindExact<Person>("Name", "Pete");
var person2 = people.FindFirstExact<Person>("Name", "Walter");
var person3 = people.FindLastExact<Person>("Name", "Joan");
}
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public override string ToString()
{
return Name + " - " + Age.ToString();
}
}
Works great - if what you're looking for is a string. Maybe enhance so I could search on any property type?
Something similar to this:
public static List<T> FindExact<T,P>(this List<T> list, string valuePropertyName, P propertyValue)
{
List<T> found = default(List<T>);
try
{
PropertyInfo info = typeof(T).GetProperty(valuePropertyName);
found = (from item in list
let value = (string)(info.GetValue(item, null))
where (P)value == propertyValue
select item).ToList();
}
catch (Exception)
{
}
return found;
}
(won't compile, but the idea is nice
If it's not broken, fix it until it is
modified 9-Jun-16 13:43pm.
|
|
|
|
|
This is specifically for finding objects in the list that contain the specified string. Feel free to adapt it to your needs.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Nice one
The only thing I would change is to use an IEnumerable<t> instead of a List<t>.
That would make the extension method more flexible and make FindExact defered execution instead of greedy because of the toList()
Some quick write in LinqPad
void Main()
{
List<Person> people = new List<Person>();
people.Add(new Person { Name = "Joan", Age = 102 });
people.Add(new Person { Name = "Pete", Age = 50 });
people.Add(new Person { Name = "Walter", Age = 65 });
people.Add(new Person { Name = "Joan", Age = 17 });
people.Add(new Person { Name = "Walter", Age = 25 });
var person1 = people.FindExact<Person>("Name", "Pete");
var person2 = people.FindFirstExact<Person>("Name", "Walter");
var person3 = people.FindLastExact<Person>("Name", "Joan");
person1.Dump();
person2.Dump();
person3.Dump();
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public override string ToString()
{
return Name + " - " + Age.ToString();
}
}
public static class Extensions
{
public static IEnumerable<T> FindExact<T>(this IEnumerable<T> list, string valuePropertyName, string text)
{
IEnumerable<T> found = default(IEnumerable<T>);
try
{
PropertyInfo info = typeof(T).GetProperty(valuePropertyName);
found = from item in list
let value = (string)(info.GetValue(item, null))
where value == text
select item;
}
catch (Exception)
{
}
return found;
}
public static T FindFirstExact<T>(this IEnumerable<T> list, string valuePropertyName, string text)
{
T found = default(T);
try
{
found = list.FindExact(valuePropertyName, text).FirstOrDefault();
}
catch (Exception)
{
}
return found;
}
public static T FindLastExact<T>(this IEnumerable<T> list, string valuePropertyName, string text)
{
T found = default(T);
try
{
found = list.Reverse().FindExact(valuePropertyName, text).First();
}
catch (Exception)
{
}
return found;
}
}
Vince
Remember the dead, fight for the living
|
|
|
|
|
Not sure you really need let in that example:
public static IEnumerable<T> FindExact<T>(this IEnumerable<T> list, string valuePropertyName, string text)
{
IEnumerable<T> found = Enumerable.Empty<T>();
try
{
PropertyInfo info = typeof(T).GetProperty(valuePropertyName);
if (info != null && info.CanRead && info.PropertyType == typeof(string) && info.GetIndexParameters().Length == 0)
{
found = list.Where(item => item != null && (string)info.GetValue(item, null) == text).ToList();
}
}
catch (Exception)
{
}
return found;
}
As Vince said, it's probably better to use IEnumerable<T> , rather than a List<T> . You can still eagerly evaluate the sequence to prevent exceptions from being thrown during enumeration.
You can eliminate most of the exceptions be checking that the property is found, can be read, returns a string , and doesn't have any index parameters; and by checking that the item is not null .
And I'd be inclined to return an empty sequence if the property is invalid or you get an exception, so that you don't have to check the returned value for null all the time.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|