ObjPropsDynamicSetter 0.4.3

dotnet add package ObjPropsDynamicSetter --version 0.4.3
                    
NuGet\Install-Package ObjPropsDynamicSetter -Version 0.4.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ObjPropsDynamicSetter" Version="0.4.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ObjPropsDynamicSetter" Version="0.4.3" />
                    
Directory.Packages.props
<PackageReference Include="ObjPropsDynamicSetter" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ObjPropsDynamicSetter --version 0.4.3
                    
#r "nuget: ObjPropsDynamicSetter, 0.4.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ObjPropsDynamicSetter&version=0.4.3
                    
Install as a Cake Addin
#tool nuget:?package=ObjPropsDynamicSetter&version=0.4.3
                    
Install as a Cake Tool

ObjPropsDynamicSetter

Coverage Mutation Score

A small library providing object extensions for getting properties information and manipulating their values via property names known at runtime. Uses reflection under the hood. Might be useful for playing with models properties in data-driven testing, but not limited to it. Supports nested properties access and access to non-public properties.

Use

Simple usage examples:

var model = new Model();
var propertyName = "Foo";

// PropertyInfo retrieval from a property
var propertyInfo = model.GetPropertyInfo(propertyName);

// Property value retrieval
var propertyValue = model.GetPropertyValue(propertyName);

// Setting new value to a property
var value = 1000;
model.SetPropertyValue(propertyName, value);

Public properties are accessible by default. To access non-public ones, optional parameter 'includeNonPublic' should be set to 'true':

model.SetPropertyValue(propertyName, value, true);

To access nested property, full path should be specified with dot ('.') as delimiter:

public class Model
{
    public NestedModel NestedModel { get; set; }
}

public class NestedModel
{
    public int Bar { get; set; }
}

// Internal initialization logic skipped for simplicity
var model = new Model();
var propertyName = "NestedModel.Bar";

var value = model.GetPropertyValue(propertyName);

Download

The latest release is on NuGet and GitHub.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.3 201 9/9/2023
0.4.2 423 8/8/2021
0.4.1 392 4/6/2021
0.4.0 408 4/6/2021
0.3.1 1,168 3/14/2021
0.3.0 891 12/28/2020
0.2.2 539 11/7/2020
0.2.0 529 10/18/2020
0.1.1 521 10/3/2020
0.1.0 553 9/27/2020