ObjPropsDynamicSetter 0.4.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package ObjPropsDynamicSetter --version 0.4.2                
NuGet\Install-Package ObjPropsDynamicSetter -Version 0.4.2                
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.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ObjPropsDynamicSetter --version 0.4.2                
#r "nuget: ObjPropsDynamicSetter, 0.4.2"                
#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.
// Install ObjPropsDynamicSetter as a Cake Addin
#addin nuget:?package=ObjPropsDynamicSetter&version=0.4.2

// Install ObjPropsDynamicSetter as a Cake Tool
#tool nuget:?package=ObjPropsDynamicSetter&version=0.4.2                

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. 
.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 173 9/9/2023
0.4.2 373 8/8/2021
0.4.1 335 4/6/2021
0.4.0 351 4/6/2021
0.3.1 1,112 3/14/2021
0.3.0 830 12/28/2020
0.2.2 477 11/7/2020
0.2.0 466 10/18/2020
0.1.1 457 10/3/2020
0.1.0 491 9/27/2020