Search code examples
c#wpflivecharts

LiveCharts: How is the AxisCore internal properties accessible from WpfView Axis implementation?


I'm looking through the code of the popular WPF graphing component LiveCharts, in an effort to port it to .NET 3.5. However, I'm not sure how this bit works:

LiveCharts.AxisCore.TopLimit is declared as an internal property. There are others too declared the same. Then, in LiveCharts.Wpf.Axis, a class variable public AxisCore Model { get; set; } is declared, and these internal properties are referenced in various methods, for example in the method public void SetRange(double min, double max).

These are separate assemblies (as far as I can tell), with Core being a portable assembly targeted only at .NET Framework 4. and WpfView a vanilla class library. How can these internal properties be accessible without using the InternalsVisibleTo attribute?


Solution

  • The Core Project is using the InternalsVisibleTo Attribute in the file AssemblyInfo.cs:

    [assembly:InternalsVisibleTo("LiveCharts.Uwp,PublicKey=002400000480000094000000060200000024000052534131000400000100010009132ae1a474e2ecf9903c1ef8945a2119aa0b9a3b4e40c43f6cb66233669e3007b4109d5c37957c2d0c5cfe7fce34366150210f83c618c18cdc8d7b763bff60419837a2185df1867c73f679e05f82b861e6ca764612eabc36d71858260b262bb9c3ad546c9692fe6379a520b6c5fc701e0ee6d071b52e9f20166fc0752ff894")] 
    [assembly:InternalsVisibleTo("LiveCharts.Wpf,PublicKey=002400000480000094000000060200000024000052534131000400000100010009132ae1a474e2ecf9903c1ef8945a2119aa0b9a3b4e40c43f6cb66233669e3007b4109d5c37957c2d0c5cfe7fce34366150210f83c618c18cdc8d7b763bff60419837a2185df1867c73f679e05f82b861e6ca764612eabc36d71858260b262bb9c3ad546c9692fe6379a520b6c5fc701e0ee6d071b52e9f20166fc0752ff894")] 
    [assembly:InternalsVisibleTo("LiveCharts.Geared,PublicKey=0024000004800000940000000602000000240000525341310004000001000100bd2e66fab8ce9a4900047ffda57d2f525cf6313dcc9d20994c5e6b3cd8fca906ba7ccd54bea5f7bd6cb503deb81d685259e355e3a9b5c21e5bc80091f08846246371b2a71ab306655651261e910adfa61be236b77d11df23a44d48f00a0e07c689f9a2daaff16d505a1c861d9854d92ed5a8a38fb28c1343fb691462873e71a1")]
    

    See https://github.com/beto-rodriguez/Live-Charts/blob/5709a2e415038d5e6ebb707f48b03927c50babec/Core/Properties/AssemblyInfo.cs#L33-L35