Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

myObjType.GetTypeInfo().DeclaredProperties.FirstOrDefault(p => p.CanRead) == null

$
0
0

Hi everybody.

I have two classes, that are mostly identical.

Since the latest updates of visual studio, all plugins, packages and anything else the TypeInfo of one of these classes is not determined as expected.
That causes sqlite to fail when creating a table for this class.

It would be great, if anyone can explain whats wrong here.

var obj1 = typeof(Data.Upgrade13To14.AnalysisViewLineUpgrade);
var info1 = obj1.GetTypeInfo();
var prop1 = info1.DeclaredProperties;
var readableprop1 = prop1.FirstOrDefault(p => p.CanRead); // not null :)

var obj2 = typeof(Data.Upgrade13To14.AnalysisViewLineNew);
var info2 = obj2.GetTypeInfo();
var prop2 = info2.DeclaredProperties;
var readableprop2 = prop2.FirstOrDefault(p => p.CanRead); // !!! null :(

Another symptom is, that the object inspection does not
show the properties of the instances of the corrupted class.

Upgrade13To14.AnalysisViewLineUpgrade inst1 = new Upgrade13To14.AnalysisViewLineUpgrade();
inst1.AnalysisViewId = 4;

Upgrade13To14.AnalysisViewLineNew inst2 = new Upgrade13To14.AnalysisViewLineNew();
inst2.AnalysisViewId = 4;

As this is my first post here, I am not allowed to attach pictures of screenshots. All properties of variable inst1 are shown. Either the public nor the "non-public"-members of the variable inst2 are listed.

Here is some environment information:
Mac OS X 10.14.4
Visual Studio Community 2019 for Mac Version 8.0.5 (build 9)
Mono 5.18.1.3 (2018-08/fdb26b0a445) (64-bit)
NETStandard.Library (2.0.3)
sqlite-net-pcl (1.5.231)

And here are the two classes:

  1. Working class

using System;
using SQLite;

namespace Library.FinanceManager.Data.Upgrade13To14
{
[Table("AnalysisViewLineUpgrade")]
public class AnalysisViewLineUpgrade
{
public enum LineType {Formula, LedgerSumCategory, LedgerSumRest, JournalLineSumCategory, JournalLineSumRest }
public enum PositiveNegative {All, Positive, Negative }
public enum DisplayType { Normal, Hidden, Strong, BackgroundIfNul, HiddenIfNul, NormalIfNul, HiddenIfNotNul, NormalIfNotNul }

public AnalysisViewLineUpgrade()
{
}

[PrimaryKey, AutoIncrement]
public int EntryNo {get;set;}
public int AnalysisViewId { get; set; }
public int LineNo { get; set; }

public LineType Type { get; set; }
public PositiveNegative ValueType { get; set; } = PositiveNegative.All;
[MaxLength(50)]
public string Description { get; set; }

[MaxLength(50)]
public string Formula { get; set; }
public DisplayType Display { get; set; }
public bool CalculateAverage { get; set; }

internal Data.Upgrade13To14.AnalysisViewLineNew Convert()
{
return new AnalysisViewLineNew()
{
ValueType = (Data.Upgrade13To14.AnalysisViewLineNew.PositiveNegative)ValueType,
AnalysisViewId = AnalysisViewId,
CalculateAverage = CalculateAverage,
Description = Description,
Display = (Data.Upgrade13To14.AnalysisViewLineNew.DisplayType)Display,
EntryNo = EntryNo,
Formula = Formula,
LineNo = LineNo,
Type = (Data.Upgrade13To14.AnalysisViewLineNew.LineType)Type
};
}
}
}

  1. Corrupt class

using System;
using SQLite;

namespace Library.FinanceManager.Data.Upgrade13To14
{
[Table("AnalysisViewLine")]
public class AnalysisViewLineNew
{
public enum LineType {Formula, LedgerSumCategory, LedgerSumRest, JournalLineSumCategory, JournalLineSumRest }
public enum PositiveNegative {All, Positive, Negative }
public enum DisplayType { Normal, Hidden, Strong, BackgroundIfNul, HiddenIfNul, NormalIfNul, HiddenIfNotNul, NormalIfNotNul }

public AnalysisViewLineNew()
{
}

[PrimaryKey, AutoIncrement]
public int EntryNo { get; set; }
public int AnalysisViewId { get; set; }
public int LineNo { get; set; }

public LineType Type { get; set; }
public PositiveNegative ValueType { get; set; } = PositiveNegative.All;
[MaxLength(50)]
public string Description { get; set; }

[MaxLength(50)]
public string Formula { get; set; }
public DisplayType Display { get; set; }
public bool CalculateAverage { get; set; }

}
}

Thanks in advance.

Martin


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>