danikf / tik4net

Manage mikrotik routers with .NET C# code via ADO.NET like API or enjoy O/R mapper like highlevel api.
Apache License 2.0
177 stars 94 forks source link

DnsStatic entry with empty name results in an exception #77

Closed AndrewSav closed 4 years ago

AndrewSav commented 4 years ago

Synopsis:

Querying DnsStatic entries when an existing entry has an empty name results in an exception

Steps to reproduce:

Expected result:

Command succeeds.

Observed result:

tik4net.TikSentenceException
  HResult=0x80131500
  Message=Missing word with name 'name'.
  Source=tik4net
  StackTrace:
   at tik4net.Api.ApiSentence.GetWordValue(String wordName) in E:\Users\andrewsav\Documents\GitHub\tik4net\tik4net\Api\ApiSentence.cs:line 89
   at tik4net.Api.ApiReSentence.GetResponseField(String fieldName) in E:\Users\andrewsav\Documents\GitHub\tik4net\tik4net\Api\ApiReSentence.cs:line 22
   at tik4net.Objects.TikCommandExtensions.GetValueFromSentence(ITikReSentence sentence, TikEntityPropertyAccessor property) in E:\Users\andrewsav\Documents\GitHub\tik4net\tik4net.objects\TikCommandExtensions.cs:line 167
   at tik4net.Objects.TikCommandExtensions.CreateObject[TEntity](ITikReSentence sentence) in E:\Users\andrewsav\Documents\GitHub\tik4net\tik4net.objects\TikCommandExtensions.cs:line 157
   at tik4net.Objects.TikCommandExtensions.<>c__0`1.<LoadList>b__0_0(ITikReSentence sentence) in E:\Users\andrewsav\Documents\GitHub\tik4net\tik4net.objects\TikCommandExtensions.cs:line 32
   at System.Linq.Enumerable.SelectListIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at tik4net.Objects.TikCommandExtensions.LoadList[TEntity](ITikCommand command) in E:\Users\andrewsav\Documents\GitHub\tik4net\tik4net.objects\TikCommandExtensions.cs:line 32
   at tik4net.Objects.TikConnectionExtensions.LoadList[TEntity](ITikConnection connection, ITikCommandParameter[] filterParameters) in E:\Users\andrewsav\Documents\GitHub\tik4net\tik4net.objects\TikConnectionExtensions.cs:line 183
   at tik4net.Objects.TikConnectionExtensions.LoadAll[TEntity](ITikConnection connection) in E:\Users\andrewsav\Documents\GitHub\tik4net\tik4net.objects\TikConnectionExtensions.cs:line 63
   at test.Program.Main(String[] args) in E:\packer\mikrotik\test\Program.cs:line 17

Additional Information

It appears, that the Name field is set mandatory here. Instead, the code should check that at least one of the fields is present: Name and Regexp.

danikf commented 4 years ago

Hi, there is not 'regexp' parameter - at least in mikrotik version 6.10. It seams that it uses overload of 'name' property ... D

danikf commented 4 years ago

Name is now optional parameter.