Open
Labels
Milestone
Description
I can't work out how to get the string "Value" of the DnsResourceRecord without having to either split the output of "ToString()" on the tab characters, or to test the DnsResourceRecords type and access a type specific "value" property.
There is a private protected abstract RecordToString() method that each deriving DnsResourceRecord type implements appropriately, Would it be possible to expose the result of this method as either a property or method?
Activity
MichaConrad commentedon Oct 23, 2018
Each type has specific properties which are parsed and populated by this library.
You're supposed to use those instead of parsing a string or binary data yourself.
Depending on the method, yes, you might have to type check the result. There are a couple of helper methods doing that for you though.
result.Answers.ARecords()returns all A records from the query result...The
RecordToStringis used internally for "pretty" printing the record. There is no point exposing that method.ToStringshould also never be used within business logic to determine the value of an object (that's true in general).gt5700 commentedon Oct 23, 2018
MichaConrad commentedon Oct 23, 2018
Well, the returned value of
ToStringmight also change in future version. There is no type safe guarantee that the returned value will be the same format or order of values.That's up to you to decide what to use ofc, just saying ;)
Using type safe properties of the actual records is usually the way to go ;)
gt5700 commentedon Oct 23, 2018
MichaConrad commentedon Oct 23, 2018
I don't really get what you mean with value only. Most resource records have many different fields (not just one value). Others have lists of strings or binary data, enum values etc...
I also don't really get what you are doing with regex over dns values to be honest... maybe you can post an example for your use case. But so far, all that sounds pretty horrible to me ;)
gt5700 commentedon Oct 23, 2018
MichaConrad commentedon Oct 24, 2018
Ok, I kind of get it. I might make that method public/rename it slightly. But that might take a while till it gets published
On the other hand, I would write a small switch statement which uses the configured query type and then, with A and AAAA you can cast the answers to
AddressRecordsand then use theIPAddressproperty. etc...That's not really a lot of code and much much safer anyways, too ;)
gt5700 commentedon Oct 25, 2018