dotnet / dotnet/msbuild

[Feature Request]: Add support for object instantiation to property functions

Open
#9,521 5 comments 0 reactions 0 assignees View on GitHub
Area: Documentation Feature Request triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Summary

Property functions currently support invoking methods but users have to come up with creative ways to new up objects. This is a proposal to add a supported syntax for instantiating objects and calling their constructors.

### Background and Motivation

Objects can be created using awkward workarounds like this one:

`$(MSBuildProjectDirectory.GetType().Assembly.GetType('System.AppDomain').GetProperty('CurrentDomain').GetValue(null, null).CreateInstanceAndUnwrap(mscorlib, Type.Of.The.Object.To.Instantiate))`

### Proposed Feature

Add a supported syntax equivalent to the C# _new_. Preferably containing the customary word _new_, although something like `$([Type.Of.The.Object.To.Instantiate]::.ctor(Parameters))` would also do.

### Alternative Designs

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.