From b995ac3912683bc007b87ea1fd94177955eddd51 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sun, 6 Feb 2022 11:14:14 +0100 Subject: [PATCH] Fixed TryFindProxyDataByTypeName (#30) * pnp * . * . * okee * ns * . * o * . * , * x * t * co * . * r * CastTo --- .../PnP/IClientContext.cs | 10 + .../PnP/IClientRuntimeContext.cs | 8 + .../ProxyInterfaceConsumer/PnP/IWeb.cs | 7 + .../ProxyInterfaceConsumer/Program.cs | 7 + .../ProxyInterfaceConsumer.csproj | 15 +- .../Extensions/MethodSymbolExtensions.cs | 4 +- .../Extensions/NamedTypeSymbolExtensions.cs | 17 +- .../Extensions/PropertySymbolExtensions.cs | 12 +- ...axNodeUtils.cs => SyntaxNodeExtensions.cs} | 78 +- .../TypeParameterSymbolExtensions.cs | 33 +- .../FileGenerators/BaseGenerator.cs | 117 ++- .../PartialInterfacesGenerator.cs | 11 +- .../ProxyClassesGenerator.AutoMapper.cs | 34 + .../FileGenerators/ProxyClassesGenerator.cs | 63 +- .../Models/ConstraintInfo.cs | 9 + .../Models/ProxyData.cs | 5 +- .../ProxyInterfaceSourceGenerator.csproj | 2 +- .../SyntaxReceiver/ProxySyntaxReceiver.cs | 14 +- .../Utils/MemberHelper.cs | 12 +- ....SharePoint.Client.ClientContextProxy.g.cs | 75 ++ ...t.SharePoint.Client.ClientObjectProxy.g.cs | 100 ++ ...oint.Client.ClientRuntimeContextProxy.g.cs | 164 ++++ .../Microsoft.SharePoint.Client.WebProxy.g.cs | 914 ++++++++++++++++++ ...urceGeneratorTests.Source.PersonProxy.g.cs | 4 +- ...eratorTests.Source.PnP.IClientContext.g.cs | 38 + ...neratorTests.Source.PnP.IClientObject.g.cs | 50 + ...ests.Source.PnP.IClientRuntimeContext.g.cs | 84 ++ ...eSourceGeneratorTests.Source.PnP.IWeb.g.cs | 444 +++++++++ .../PnPTests.cs | 33 + .../ProxyInterfaceSourceGeneratorTest.cs | 93 +- .../ProxyInterfaceSourceGeneratorTests.csproj | 11 +- .../Source/PnP/IClientContext.cs | 9 + .../Source/PnP/IClientObject.cs | 6 + .../Source/PnP/IClientRuntimeContext.cs | 27 + .../Source/PnP/IWeb.cs | 8 + 35 files changed, 2361 insertions(+), 157 deletions(-) create mode 100644 src-examples/ProxyInterfaceConsumer/PnP/IClientContext.cs create mode 100644 src-examples/ProxyInterfaceConsumer/PnP/IClientRuntimeContext.cs create mode 100644 src-examples/ProxyInterfaceConsumer/PnP/IWeb.cs rename src/ProxyInterfaceSourceGenerator/Extensions/{SyntaxNodeUtils.cs => SyntaxNodeExtensions.cs} (92%) create mode 100644 src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.AutoMapper.cs create mode 100644 src/ProxyInterfaceSourceGenerator/Models/ConstraintInfo.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientContextProxy.g.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientObjectProxy.g.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.WebProxy.g.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/PnPTests.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientContext.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientObject.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientRuntimeContext.cs create mode 100644 tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IWeb.cs diff --git a/src-examples/ProxyInterfaceConsumer/PnP/IClientContext.cs b/src-examples/ProxyInterfaceConsumer/PnP/IClientContext.cs new file mode 100644 index 0000000..8de2d43 --- /dev/null +++ b/src-examples/ProxyInterfaceConsumer/PnP/IClientContext.cs @@ -0,0 +1,10 @@ +using Microsoft.SharePoint.Client; + +namespace ProxyInterfaceConsumer.PnP +{ + [ProxyInterfaceGenerator.Proxy(typeof(ClientContext))] + public partial interface IClientContext + { + // public virtual void X(); + } +} \ No newline at end of file diff --git a/src-examples/ProxyInterfaceConsumer/PnP/IClientRuntimeContext.cs b/src-examples/ProxyInterfaceConsumer/PnP/IClientRuntimeContext.cs new file mode 100644 index 0000000..b183b56 --- /dev/null +++ b/src-examples/ProxyInterfaceConsumer/PnP/IClientRuntimeContext.cs @@ -0,0 +1,8 @@ +namespace ProxyInterfaceConsumer.PnP +{ + [ProxyInterfaceGenerator.Proxy(typeof(Microsoft.SharePoint.Client.ClientRuntimeContext))] + public partial interface IClientRuntimeContext + { + + } +} \ No newline at end of file diff --git a/src-examples/ProxyInterfaceConsumer/PnP/IWeb.cs b/src-examples/ProxyInterfaceConsumer/PnP/IWeb.cs new file mode 100644 index 0000000..a41a84e --- /dev/null +++ b/src-examples/ProxyInterfaceConsumer/PnP/IWeb.cs @@ -0,0 +1,7 @@ +namespace ProxyInterfaceConsumer.PnP +{ + [ProxyInterfaceGenerator.Proxy(typeof(Microsoft.SharePoint.Client.Web))] + public partial interface IWeb + { + } +} \ No newline at end of file diff --git a/src-examples/ProxyInterfaceConsumer/Program.cs b/src-examples/ProxyInterfaceConsumer/Program.cs index 3ec831f..869b590 100644 --- a/src-examples/ProxyInterfaceConsumer/Program.cs +++ b/src-examples/ProxyInterfaceConsumer/Program.cs @@ -3,6 +3,8 @@ using DifferentNamespace; using System; using System.Collections.Generic; using System.Text.Json; +using Microsoft.SharePoint.Client; +using ProxyInterfaceConsumer.PnP; namespace ProxyInterfaceConsumer { @@ -15,6 +17,11 @@ namespace ProxyInterfaceConsumer public static void Main() { + var cp = new ClientContextProxy(new ClientContext("x")); + cp.ExecuteQuery(); + var webP = cp.Web; + + var t = new TestProxy(new Test()); IPersonT pT = new PersonTProxy(new PersonT()); diff --git a/src-examples/ProxyInterfaceConsumer/ProxyInterfaceConsumer.csproj b/src-examples/ProxyInterfaceConsumer/ProxyInterfaceConsumer.csproj index 0b862a7..0941af8 100644 --- a/src-examples/ProxyInterfaceConsumer/ProxyInterfaceConsumer.csproj +++ b/src-examples/ProxyInterfaceConsumer/ProxyInterfaceConsumer.csproj @@ -1,4 +1,4 @@ - + net5.0 @@ -20,10 +20,23 @@ + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/Extensions/MethodSymbolExtensions.cs b/src/ProxyInterfaceSourceGenerator/Extensions/MethodSymbolExtensions.cs index 96826f2..818fcd8 100644 --- a/src/ProxyInterfaceSourceGenerator/Extensions/MethodSymbolExtensions.cs +++ b/src/ProxyInterfaceSourceGenerator/Extensions/MethodSymbolExtensions.cs @@ -7,6 +7,6 @@ internal static class MethodSymbolExtensions public static string GetMethodNameWithOptionalTypeParameters(this IMethodSymbol method) => !method.IsGenericMethod ? method.Name : $"{method.Name}<{string.Join(", ", method.TypeParameters.Select(tp => tp.Name))}>"; - public static string GetWhereStatement(this IMethodSymbol method) => - !method.IsGenericMethod ? string.Empty : string.Join("", method.TypeParameters.Select(tp => tp.GetWhereStatement())); + //public static string GetWhereStatement(this IMethodSymbol method) => + // !method.IsGenericMethod ? string.Empty : string.Join("", method.TypeParameters.Select(tp => tp.GetWhereConstraints())); } \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/Extensions/NamedTypeSymbolExtensions.cs b/src/ProxyInterfaceSourceGenerator/Extensions/NamedTypeSymbolExtensions.cs index 2c7ba90..c9afff2 100644 --- a/src/ProxyInterfaceSourceGenerator/Extensions/NamedTypeSymbolExtensions.cs +++ b/src/ProxyInterfaceSourceGenerator/Extensions/NamedTypeSymbolExtensions.cs @@ -45,22 +45,7 @@ internal static class NamedTypeSymbolExtensions return namedTypeSymbol.OriginalDefinition.ToString();// str.ToString(); } - public static string ResolveInterfaceNameWithOptionalTypeConstraints(this INamedTypeSymbol namedTypeSymbol, string interfaceName) - { - if (!namedTypeSymbol.IsGenericType) - { - return interfaceName; - } - - var str = new StringBuilder($"{interfaceName}<{string.Join(", ", namedTypeSymbol.TypeArguments.Select(ta => ta.Name))}>"); - - foreach (var typeParameterSymbol in namedTypeSymbol.TypeArguments.OfType()) - { - str.Append(typeParameterSymbol.GetWhereStatement()); - } - - return str.ToString(); - } + /// /// See https://stackoverflow.com/questions/24157101/roslyns-gettypebymetadataname-and-generic-types diff --git a/src/ProxyInterfaceSourceGenerator/Extensions/PropertySymbolExtensions.cs b/src/ProxyInterfaceSourceGenerator/Extensions/PropertySymbolExtensions.cs index 9505f49..094c08f 100644 --- a/src/ProxyInterfaceSourceGenerator/Extensions/PropertySymbolExtensions.cs +++ b/src/ProxyInterfaceSourceGenerator/Extensions/PropertySymbolExtensions.cs @@ -37,9 +37,19 @@ internal static class PropertySymbolExtensions "_Instance" : $"{targetClassSymbol.Symbol}"; + string overrideOrVirtual = string.Empty; + if (property.IsOverride) + { + overrideOrVirtual = "override "; + } + else if (property.IsVirtual) + { + overrideOrVirtual = "virtual "; + } + var get = property.GetMethod != null ? $"get => _mapper.Map<{overrideType}>({instance}.{property.GetSanitizedName()}); " : string.Empty; var set = property.SetMethod != null ? $"set => {instance}.{property.GetSanitizedName()} = _mapper.Map<{property.Type}>(value); " : string.Empty; - return $"{overrideType} {property.GetSanitizedName()} {{ {get}{set}}}"; + return $"{overrideOrVirtual}{overrideType} {property.GetSanitizedName()} {{ {get}{set}}}"; } } \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/Extensions/SyntaxNodeUtils.cs b/src/ProxyInterfaceSourceGenerator/Extensions/SyntaxNodeExtensions.cs similarity index 92% rename from src/ProxyInterfaceSourceGenerator/Extensions/SyntaxNodeUtils.cs rename to src/ProxyInterfaceSourceGenerator/Extensions/SyntaxNodeExtensions.cs index 4aed807..16b0a1a 100644 --- a/src/ProxyInterfaceSourceGenerator/Extensions/SyntaxNodeUtils.cs +++ b/src/ProxyInterfaceSourceGenerator/Extensions/SyntaxNodeExtensions.cs @@ -1,40 +1,40 @@ -using Microsoft.CodeAnalysis; -using System.Diagnostics.CodeAnalysis; - -namespace ProxyInterfaceSourceGenerator.Extensions; - -internal static class SyntaxNodeUtils -{ - // https://stackoverflow.com/questions/20458457/getting-class-fullname-including-namespace-from-roslyn-classdeclarationsyntax - public static bool TryGetParentSyntax(this SyntaxNode? syntaxNode, [NotNullWhen(true)] out T? result) where T : SyntaxNode - { - result = null; - - if (syntaxNode is null) - { - return false; - } - - try - { - syntaxNode = syntaxNode.Parent; - - if (syntaxNode is null) - { - return false; - } - - if (syntaxNode.GetType() == typeof(T)) - { - result = (T)syntaxNode; - return true; - } - - return TryGetParentSyntax(syntaxNode, out result); - } - catch - { - return false; - } - } +using Microsoft.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; + +namespace ProxyInterfaceSourceGenerator.Extensions; + +internal static class SyntaxNodeExtensions +{ + // https://stackoverflow.com/questions/20458457/getting-class-fullname-including-namespace-from-roslyn-classdeclarationsyntax + public static bool TryGetParentSyntax(this SyntaxNode? syntaxNode, [NotNullWhen(true)] out T? result) where T : SyntaxNode + { + result = null; + + if (syntaxNode is null) + { + return false; + } + + try + { + syntaxNode = syntaxNode.Parent; + + if (syntaxNode is null) + { + return false; + } + + if (syntaxNode.GetType() == typeof(T)) + { + result = (T)syntaxNode; + return true; + } + + return TryGetParentSyntax(syntaxNode, out result); + } + catch + { + return false; + } + } } \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/Extensions/TypeParameterSymbolExtensions.cs b/src/ProxyInterfaceSourceGenerator/Extensions/TypeParameterSymbolExtensions.cs index 4ea595b..2e642f2 100644 --- a/src/ProxyInterfaceSourceGenerator/Extensions/TypeParameterSymbolExtensions.cs +++ b/src/ProxyInterfaceSourceGenerator/Extensions/TypeParameterSymbolExtensions.cs @@ -1,37 +1,10 @@ +using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; +using ProxyInterfaceSourceGenerator.Models; namespace ProxyInterfaceSourceGenerator.Extensions; internal static class TypeParameterSymbolExtensions { - /// - /// https://www.codeproject.com/Articles/871704/Roslyn-Code-Analysis-in-Easy-Samples-Part-2 - /// - public static string GetWhereStatement(this ITypeParameterSymbol typeParameterSymbol) - { - var constraints = new List(); - if (typeParameterSymbol.HasReferenceTypeConstraint) - { - constraints.Add("class"); - } - - if (typeParameterSymbol.HasValueTypeConstraint) - { - constraints.Add("struct"); - } - - if (typeParameterSymbol.HasConstructorConstraint) - { - constraints.Add("new()"); - } - - constraints.AddRange(typeParameterSymbol.ConstraintTypes.OfType().Select(contstraintType => contstraintType.GetFullType())); - - if (!constraints.Any()) - { - return string.Empty; - } - - return $" where {typeParameterSymbol.Name} : {string.Join(", ", constraints)}"; - } + } \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/FileGenerators/BaseGenerator.cs b/src/ProxyInterfaceSourceGenerator/FileGenerators/BaseGenerator.cs index 30d2201..29247e7 100644 --- a/src/ProxyInterfaceSourceGenerator/FileGenerators/BaseGenerator.cs +++ b/src/ProxyInterfaceSourceGenerator/FileGenerators/BaseGenerator.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Text; using Microsoft.CodeAnalysis; using ProxyInterfaceSourceGenerator.Extensions; using ProxyInterfaceSourceGenerator.Models; @@ -26,14 +27,118 @@ internal abstract class BaseGenerator return GetReplacedType(property.Type, out isReplaced); } + protected bool TryFindProxyDataByTypeName(string type, [NotNullWhen(true)] out ProxyData? proxyData) + { + proxyData = Context.CandidateInterfaces.Values.FirstOrDefault(x => x.FullRawTypeName == type); + if (proxyData != null) + { + return true; + } + + foreach (var ci in Context.CandidateInterfaces.Values) + { + foreach (var u in ci.Usings) + { + if ($"{u}.{ci.FullRawTypeName}" == type) + { + proxyData = ci; + return true; + } + } + } + + return false; + } + + protected string GetWhereStatementFromMethod(IMethodSymbol method) + { + if (!method.IsGenericMethod) + { + return string.Empty; + } + + var list = new List(); + foreach (var typeParameterSymbol in method.TypeParameters) + { + if (TryGetWhereConstraints(typeParameterSymbol, false, out var constraint)) + { + list.Add(constraint.ToString()); + } + } + + return string.Concat(list); + } + + protected string ResolveInterfaceNameWithOptionalTypeConstraints(INamedTypeSymbol namedTypeSymbol, string interfaceName) + { + if (!namedTypeSymbol.IsGenericType) + { + return interfaceName; + } + + var str = new StringBuilder($"{interfaceName}<{string.Join(", ", namedTypeSymbol.TypeArguments.Select(ta => ta.Name))}>"); + + foreach (var typeParameterSymbol in namedTypeSymbol.TypeArguments.OfType()) + { + if (TryGetWhereConstraints(typeParameterSymbol, false, out var constraint)) + { + str.Append(constraint); + } + } + + return str.ToString(); + } + + /// + /// https://www.codeproject.com/Articles/871704/Roslyn-Code-Analysis-in-Easy-Samples-Part-2 + /// + public bool TryGetWhereConstraints(ITypeParameterSymbol typeParameterSymbol, bool replaceIt, [NotNullWhen(true)] out ConstraintInfo? constraint) + { + var constraints = new List(); + if (typeParameterSymbol.HasReferenceTypeConstraint) + { + constraints.Add("class"); + } + + if (typeParameterSymbol.HasValueTypeConstraint) + { + constraints.Add("struct"); + } + + if (typeParameterSymbol.HasConstructorConstraint) + { + constraints.Add("new()"); + } + + foreach (var namedTypeSymbol in typeParameterSymbol.ConstraintTypes.OfType()) + { + if (replaceIt) + { + constraints.Add(GetReplacedType(namedTypeSymbol, out _)); + } + else + { + constraints.Add(namedTypeSymbol.GetFullType()); + } + } + + if (!constraints.Any()) + { + constraint = null; + return false; + } + + constraint = new(typeParameterSymbol.Name, constraints); + return true; + } + protected string GetReplacedType(ITypeSymbol typeSymbol, out bool isReplaced) { isReplaced = false; var typeSymbolAsString = typeSymbol.ToString(); - var existing = Context.CandidateInterfaces.Values.FirstOrDefault(x => x.RawTypeName == typeSymbolAsString); - if (existing is not null) + if (TryFindProxyDataByTypeName(typeSymbolAsString, out var existing)) { if (!Context.ReplacedTypes.ContainsKey(typeSymbolAsString)) { @@ -50,17 +155,17 @@ internal abstract class BaseGenerator foreach (var typeArgument in namedTypedSymbol.TypeArguments) { var typeArgumentAsString = typeArgument.ToString(); - var exist = Context.CandidateInterfaces.Values.FirstOrDefault(x => x.RawTypeName == typeArgumentAsString); - if (exist is not null) + + if (TryFindProxyDataByTypeName(typeArgumentAsString, out var existingTypeArgument)) { isReplaced = true; if (!Context.ReplacedTypes.ContainsKey(typeArgumentAsString)) { - Context.ReplacedTypes.Add(typeArgumentAsString, exist.FullInterfaceName); + Context.ReplacedTypes.Add(typeArgumentAsString, existingTypeArgument.FullInterfaceName); } - propertyTypeAsStringToBeModified = propertyTypeAsStringToBeModified.Replace(typeArgumentAsString, exist.FullInterfaceName); + propertyTypeAsStringToBeModified = propertyTypeAsStringToBeModified.Replace(typeArgumentAsString, existingTypeArgument.FullInterfaceName); } } diff --git a/src/ProxyInterfaceSourceGenerator/FileGenerators/PartialInterfacesGenerator.cs b/src/ProxyInterfaceSourceGenerator/FileGenerators/PartialInterfacesGenerator.cs index 0500330..774efd4 100644 --- a/src/ProxyInterfaceSourceGenerator/FileGenerators/PartialInterfacesGenerator.cs +++ b/src/ProxyInterfaceSourceGenerator/FileGenerators/PartialInterfacesGenerator.cs @@ -36,12 +36,12 @@ internal class PartialInterfacesGenerator : BaseGenerator, IFilesGenerator return false; } - if (!TryGetNamedTypeSymbolByFullName(TypeKind.Class, pd.TypeName, pd.Usings, out var targetClassSymbol)) + if (!TryGetNamedTypeSymbolByFullName(TypeKind.Class, pd.FullTypeName, pd.Usings, out var targetClassSymbol)) { return false; } - var interfaceName = targetClassSymbol.Symbol.ResolveInterfaceNameWithOptionalTypeConstraints(pd.ShortInterfaceName); + var interfaceName = ResolveInterfaceNameWithOptionalTypeConstraints(targetClassSymbol.Symbol, pd.ShortInterfaceName); fileData = new FileData( $"{sourceInterfaceSymbol.Symbol.GetFileName()}.g.cs", @@ -113,7 +113,12 @@ namespace {ns} methodParameters.Add($"{ps.GetParamsPrefix()}{ps.GetRefPrefix()}{type} {ps.GetSanitizedName()}{ps.GetDefaultValue()}"); } - str.AppendLine($" {GetReplacedType(method.ReturnType, out _)} {method.GetMethodNameWithOptionalTypeParameters()}({string.Join(", ", methodParameters)}){method.GetWhereStatement()};"); + var whereStatement = GetWhereStatementFromMethod(method); + + //public static string GetWhereStatement(this IMethodSymbol method) => + // !method.IsGenericMethod ? string.Empty : string.Join("", method.TypeParameters.Select(tp => tp.GetWhereConstraints())); + + str.AppendLine($" {GetReplacedType(method.ReturnType, out _)} {method.GetMethodNameWithOptionalTypeParameters()}({string.Join(", ", methodParameters)}){whereStatement};"); str.AppendLine(); } diff --git a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.AutoMapper.cs b/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.AutoMapper.cs new file mode 100644 index 0000000..d3945af --- /dev/null +++ b/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.AutoMapper.cs @@ -0,0 +1,34 @@ +using System.Text; +using ProxyInterfaceSourceGenerator.Extensions; + +namespace ProxyInterfaceSourceGenerator.FileGenerators; + +internal partial class ProxyClassesGenerator +{ + private static string GeneratePrivateAutoMapper() + { + return " private readonly IMapper _mapper;"; + } + + private string GenerateMapperConfigurationForAutoMapper() + { + var str = new StringBuilder(); + + str.AppendLine(" _mapper = new MapperConfiguration(cfg =>"); + str.AppendLine(" {"); + foreach (var replacedType in Context.ReplacedTypes) + { + TryFindProxyDataByTypeName(replacedType.Key, out var fullTypeName); + var classNameProxy = $"{fullTypeName!.Namespace}.{fullTypeName.ShortTypeName}Proxy"; + + var instance = $"instance{(replacedType.Key + replacedType.Value).GetDeterministicHashCodeAsString()}"; + var proxy = $"proxy{(replacedType.Value + replacedType.Key).GetDeterministicHashCodeAsString()}"; + + str.AppendLine($" cfg.CreateMap<{replacedType.Key}, {replacedType.Value}>().ConstructUsing({instance} => new {classNameProxy}({instance}));"); + str.AppendLine($" cfg.CreateMap<{replacedType.Value}, {replacedType.Key}>().ConstructUsing({proxy} => (({classNameProxy}) {proxy})._Instance);"); + } + str.AppendLine(" }).CreateMapper();"); + + return str.ToString(); + } +} \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.cs b/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.cs index 6e2bf9c..bb372fb 100644 --- a/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.cs +++ b/src/ProxyInterfaceSourceGenerator/FileGenerators/ProxyClassesGenerator.cs @@ -30,20 +30,20 @@ internal partial class ProxyClassesGenerator : BaseGenerator, IFilesGenerator { fileData = default; - if (!TryGetNamedTypeSymbolByFullName(TypeKind.Class, pd.TypeName, pd.Usings, out var targetClassSymbol)) + if (!TryGetNamedTypeSymbolByFullName(TypeKind.Class, pd.FullTypeName, pd.Usings, out var targetClassSymbol)) { return false; } - var interfaceName = targetClassSymbol.Symbol.ResolveInterfaceNameWithOptionalTypeConstraints(pd.ShortInterfaceName); + var interfaceName = ResolveInterfaceNameWithOptionalTypeConstraints(targetClassSymbol.Symbol, pd.ShortInterfaceName); var className = targetClassSymbol.Symbol.ResolveProxyClassName(); var constructorName = $"{targetClassSymbol.Symbol.Name}Proxy"; var extendsProxyClasses = targetClassSymbol.BaseTypes .Join( - Context.CandidateInterfaces.Values.Select(v => v.RawTypeName), - bt => bt.ToString(), - ci => ci, (bt, _) => bt + Context.CandidateInterfaces.Values, + namedTypeSymbol => namedTypeSymbol.ToString(), + proxyData => proxyData.FullRawTypeName, (_, proxyData) => proxyData ).ToList(); fileData = new FileData( @@ -57,20 +57,19 @@ internal partial class ProxyClassesGenerator : BaseGenerator, IFilesGenerator private string CreateProxyClassCode( ProxyData pd, ClassSymbol targetClassSymbol, - List extendsProxyClasses, + List extendsProxyClasses, string interfaceName, string className, string constructorName) { - var extendsFullNames = extendsProxyClasses.Select(e => e.ResolveFullProxyClassName()).ToList(); - var extends = extendsProxyClasses.Any() ? $"{string.Join(", ", extendsFullNames)}, " : string.Empty; + var extends = extendsProxyClasses.Select(e => $"{e.Namespace}.{e.ShortTypeName}Proxy, ").FirstOrDefault() ?? string.Empty; var @base = extendsProxyClasses.Any() ? " : base(instance)" : string.Empty; var @new = extendsProxyClasses.Any() ? "new " : string.Empty; - var instanceBaseDefinition = extendsProxyClasses.Any() ? $"public {extendsProxyClasses.First()} _InstanceBase {{ get; }}\r\n" : string.Empty; + var instanceBaseDefinition = extendsProxyClasses.Any() ? $"public {extendsProxyClasses[0].FullRawTypeName} _InstanceBase {{ get; }}\r\n" : string.Empty; var instanceBaseSet = extendsProxyClasses.Any() ? "_InstanceBase = instance;" : string.Empty; var properties = GeneratePublicProperties(targetClassSymbol, pd.ProxyBaseClasses); - var methods = GeneratePublicMethods(targetClassSymbol, pd.ProxyBaseClasses); + var methods = GeneratePublicMethods(targetClassSymbol, pd.ProxyBaseClasses, extendsProxyClasses); var events = GenerateEvents(targetClassSymbol, pd.ProxyBaseClasses); var configurationForAutoMapper = string.Empty; @@ -123,29 +122,6 @@ namespace {pd.Namespace} {(SupportsNullable ? "#nullable disable" : string.Empty)}"; } - private static string GeneratePrivateAutoMapper() - { - return " private readonly IMapper _mapper;"; - } - - private string GenerateMapperConfigurationForAutoMapper() - { - var str = new StringBuilder(); - - str.AppendLine(" _mapper = new MapperConfiguration(cfg =>"); - str.AppendLine(" {"); - foreach (var replacedType in Context.ReplacedTypes) - { - var proxy = $"{replacedType.Key}Proxy"; - - str.AppendLine($" cfg.CreateMap<{replacedType.Key}, {replacedType.Value}>().ConstructUsing(instance => new {proxy}(instance));"); - str.AppendLine($" cfg.CreateMap<{replacedType.Value}, {replacedType.Key}>().ConstructUsing(proxy => (({proxy}) proxy)._Instance);"); - } - str.AppendLine(" }).CreateMapper();"); - - return str.ToString(); - } - private string GeneratePublicProperties(ClassSymbol targetClassSymbol, bool proxyBaseClasses) { var str = new StringBuilder(); @@ -153,6 +129,7 @@ namespace {pd.Namespace} foreach (var property in MemberHelper.GetPublicProperties(targetClassSymbol, proxyBaseClasses)) { var type = GetPropertyType(property, out var isReplaced); + if (isReplaced) { str.AppendLine($" public {property.ToPropertyTextForClass(targetClassSymbol, type)}"); @@ -167,7 +144,7 @@ namespace {pd.Namespace} return str.ToString(); } - private string GeneratePublicMethods(ClassSymbol targetClassSymbol, bool proxyBaseClasses) + private string GeneratePublicMethods(ClassSymbol targetClassSymbol, bool proxyBaseClasses, List extendsProxyClasses) { var str = new StringBuilder(); foreach (var method in MemberHelper.GetPublicMethods(targetClassSymbol, proxyBaseClasses)) @@ -183,9 +160,25 @@ namespace {pd.Namespace} invokeParameters.Add($"{ps.GetRefPrefix()}{ps.GetSanitizedName()}_"); } + string overrideOrVirtual = string.Empty; + if (method.IsOverride && method.OverriddenMethod != null) + { + var baseType = method.OverriddenMethod.ContainingType.GetFullType(); + if (TryGetNamedTypeSymbolByFullName(TypeKind.Class, baseType, Enumerable.Empty(), out _)) + { + overrideOrVirtual = "override "; + } + } + else if (method.IsVirtual) + { + overrideOrVirtual = "virtual "; + } + string returnTypeAsString = GetReplacedType(method.ReturnType, out var returnIsReplaced); - str.AppendLine($" public {returnTypeAsString} {method.GetMethodNameWithOptionalTypeParameters()}({string.Join(", ", methodParameters)}){method.GetWhereStatement()}"); + var whereStatement = GetWhereStatementFromMethod(method); + + str.AppendLine($" public {overrideOrVirtual}{returnTypeAsString} {method.GetMethodNameWithOptionalTypeParameters()}({string.Join(", ", methodParameters)}){whereStatement}"); str.AppendLine(" {"); foreach (var ps in method.Parameters) { diff --git a/src/ProxyInterfaceSourceGenerator/Models/ConstraintInfo.cs b/src/ProxyInterfaceSourceGenerator/Models/ConstraintInfo.cs new file mode 100644 index 0000000..7a0506a --- /dev/null +++ b/src/ProxyInterfaceSourceGenerator/Models/ConstraintInfo.cs @@ -0,0 +1,9 @@ +namespace ProxyInterfaceSourceGenerator.Models; + +internal record ConstraintInfo(string Type, List Items) +{ + public override string ToString() + { + return Items.Any() ? $" where {Type} : {string.Join(", ", Items)}" : string.Empty; + } +} \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/Models/ProxyData.cs b/src/ProxyInterfaceSourceGenerator/Models/ProxyData.cs index 510b158..1340fa4 100644 --- a/src/ProxyInterfaceSourceGenerator/Models/ProxyData.cs +++ b/src/ProxyInterfaceSourceGenerator/Models/ProxyData.cs @@ -5,8 +5,9 @@ internal record ProxyData string Namespace, string ShortInterfaceName, string FullInterfaceName, - string RawTypeName, - string TypeName, + string FullRawTypeName, + string ShortTypeName, + string FullTypeName, List Usings, bool ProxyBaseClasses ); \ No newline at end of file diff --git a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj index f091669..d02dfc4 100644 --- a/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj +++ b/src/ProxyInterfaceSourceGenerator/ProxyInterfaceSourceGenerator.csproj @@ -1,7 +1,7 @@ - 0.0.14 + 0.0.15-preview-02 netstandard2.0 {12344228-91F4-4502-9595-39584E5ABB34} 10 diff --git a/src/ProxyInterfaceSourceGenerator/SyntaxReceiver/ProxySyntaxReceiver.cs b/src/ProxyInterfaceSourceGenerator/SyntaxReceiver/ProxySyntaxReceiver.cs index ffc120e..e133ffc 100644 --- a/src/ProxyInterfaceSourceGenerator/SyntaxReceiver/ProxySyntaxReceiver.cs +++ b/src/ProxyInterfaceSourceGenerator/SyntaxReceiver/ProxySyntaxReceiver.cs @@ -59,9 +59,9 @@ internal class ProxySyntaxReceiver : ISyntaxReceiver } } - var type = ((TypeOfExpressionSyntax)argumentList.Arguments[0].Expression).Type; + var typeSyntax = ((TypeOfExpressionSyntax)argumentList.Arguments[0].Expression).Type; + string rawTypeName = typeSyntax.ToString(); - string rawTypeName = type.ToString(); bool proxyAllClasses; try { @@ -71,14 +71,15 @@ internal class ProxySyntaxReceiver : ISyntaxReceiver { proxyAllClasses = false; } - + data = new ( ns, interfaceDeclarationSyntax.Identifier.ToString(), $"{ns}.{interfaceDeclarationSyntax.Identifier}", rawTypeName, - ConvertTypeName(rawTypeName), + ConvertTypeName(rawTypeName).Split('.').Last(), // ShortTypeName + ConvertTypeName(rawTypeName), // FullTypeName usings, proxyAllClasses ); @@ -86,6 +87,11 @@ internal class ProxySyntaxReceiver : ISyntaxReceiver return true; } + private string GetFullTypeName(TypeSyntax typeSyntax, string ns) + { + return ""; + } + private static string ConvertTypeName(string typeName) { return !(typeName.Contains('<') && typeName.Contains('>')) ? diff --git a/src/ProxyInterfaceSourceGenerator/Utils/MemberHelper.cs b/src/ProxyInterfaceSourceGenerator/Utils/MemberHelper.cs index d5467f8..830ffe8 100644 --- a/src/ProxyInterfaceSourceGenerator/Utils/MemberHelper.cs +++ b/src/ProxyInterfaceSourceGenerator/Utils/MemberHelper.cs @@ -25,10 +25,7 @@ internal static class MemberHelper bool proxyBaseClasses, Func? filter = null) { - if (filter is null) - { - filter = _ => true; - } + filter ??= _ => true; return GetPublicMembers(classSymbol, proxyBaseClasses, @@ -43,16 +40,13 @@ internal static class MemberHelper bool proxyBaseClasses, Func? filter = null) { - if (filter is null) - { - filter = _ => true; - } + filter ??= _ => true; #pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type. #pragma warning disable RS1024 // Compare symbols correctly return GetPublicMembers(classSymbol, proxyBaseClasses, - m => m.MethodKind == MethodKind.EventAdd || m.MethodKind == MethodKind.EventRemove/* || m.MethodKind == MethodKind.EventRaise*/, + m => m.MethodKind is MethodKind.EventAdd or MethodKind.EventRemove/* || m.MethodKind == MethodKind.EventRaise*/, filter) .GroupBy(e => e.AssociatedSymbol); #pragma warning restore RS1024 // Compare symbols correctly diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientContextProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientContextProxy.g.cs new file mode 100644 index 0000000..209399b --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientContextProxy.g.cs @@ -0,0 +1,75 @@ +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; +using AutoMapper; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial class ClientContextProxy : ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy, IClientContext + { + public new Microsoft.SharePoint.Client.ClientContext _Instance { get; } + public Microsoft.SharePoint.Client.ClientRuntimeContext _InstanceBase { get; } + + + public ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb Web { get => _mapper.Map(_Instance.Web); } + + public Microsoft.SharePoint.Client.Site Site { get => _Instance.Site; } + + public Microsoft.SharePoint.Client.RequestResources RequestResources { get => _Instance.RequestResources; } + + public System.Version ServerVersion { get => _Instance.ServerVersion; } + + + + public Microsoft.SharePoint.Client.FormDigestInfo GetFormDigestDirect() + { + var result_333437737 = _Instance.GetFormDigestDirect(); + return result_333437737; + } + + public override void ExecuteQuery() + { + _Instance.ExecuteQuery(); + } + + public override System.Threading.Tasks.Task ExecuteQueryAsync() + { + var result_737681611 = _Instance.ExecuteQueryAsync(); + return result_737681611; + } + + + + + + public ClientContextProxy(Microsoft.SharePoint.Client.ClientContext instance) : base(instance) + { + _Instance = instance; + _InstanceBase = instance; + + _mapper = new MapperConfiguration(cfg => + { + cfg.CreateMap().ConstructUsing(instance_205293328 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy(instance_205293328)); + cfg.CreateMap().ConstructUsing(proxy1345472640 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy) proxy1345472640)._Instance); + cfg.CreateMap().ConstructUsing(instance_895746668 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy(instance_895746668)); + cfg.CreateMap().ConstructUsing(proxy1674261376 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy) proxy1674261376)._Instance); + cfg.CreateMap().ConstructUsing(instance_1283184912 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientContextProxy(instance_1283184912)); + cfg.CreateMap().ConstructUsing(proxy1267236400 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientContextProxy) proxy1267236400)._Instance); + cfg.CreateMap().ConstructUsing(instance_1865313808 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.WebProxy(instance_1865313808)); + cfg.CreateMap().ConstructUsing(proxy2115366516 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.WebProxy) proxy2115366516)._Instance); + }).CreateMapper(); + + } + + private readonly IMapper _mapper; + } +} +#nullable disable \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientObjectProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientObjectProxy.g.cs new file mode 100644 index 0000000..074580a --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientObjectProxy.g.cs @@ -0,0 +1,100 @@ +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; +using AutoMapper; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial class ClientObjectProxy : IClientObject + { + public Microsoft.SharePoint.Client.ClientObject _Instance { get; } + + + public ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext Context { get => _mapper.Map(_Instance.Context); } + + public object Tag { get => _Instance.Tag; set => _Instance.Tag = value; } + + public Microsoft.SharePoint.Client.ObjectPath Path { get => _Instance.Path; } + + public string ObjectVersion { get => _Instance.ObjectVersion; set => _Instance.ObjectVersion = value; } + + public bool? ServerObjectIsNull { get => _Instance.ServerObjectIsNull; } + + public ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject TypedObject { get => _mapper.Map(_Instance.TypedObject); } + + + + public virtual void FromJson(Microsoft.SharePoint.Client.JsonReader reader) + { + Microsoft.SharePoint.Client.JsonReader reader_ = reader; + _Instance.FromJson(reader_); + } + + public virtual bool CustomFromJson(Microsoft.SharePoint.Client.JsonReader reader) + { + Microsoft.SharePoint.Client.JsonReader reader_ = reader; + var result__636829107 = _Instance.CustomFromJson(reader_); + return result__636829107; + } + + public void Retrieve() + { + _Instance.Retrieve(); + } + + public void Retrieve(params string[] propertyNames) + { + string[] propertyNames_ = propertyNames; + _Instance.Retrieve(propertyNames_); + } + + public virtual void RefreshLoad() + { + _Instance.RefreshLoad(); + } + + public bool IsPropertyAvailable(string propertyName) + { + string propertyName_ = propertyName; + var result_1607091274 = _Instance.IsPropertyAvailable(propertyName_); + return result_1607091274; + } + + public bool IsObjectPropertyInstantiated(string propertyName) + { + string propertyName_ = propertyName; + var result__181021484 = _Instance.IsObjectPropertyInstantiated(propertyName_); + return result__181021484; + } + + + + + + public ClientObjectProxy(Microsoft.SharePoint.Client.ClientObject instance) + { + _Instance = instance; + + + _mapper = new MapperConfiguration(cfg => + { + cfg.CreateMap().ConstructUsing(instance_205293328 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy(instance_205293328)); + cfg.CreateMap().ConstructUsing(proxy1345472640 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy) proxy1345472640)._Instance); + cfg.CreateMap().ConstructUsing(instance_895746668 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy(instance_895746668)); + cfg.CreateMap().ConstructUsing(proxy1674261376 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy) proxy1674261376)._Instance); + }).CreateMapper(); + + } + + private readonly IMapper _mapper; + } +} +#nullable disable \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs new file mode 100644 index 0000000..15dda9b --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs @@ -0,0 +1,164 @@ +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; +using AutoMapper; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial class ClientRuntimeContextProxy : IClientRuntimeContext + { + public Microsoft.SharePoint.Client.ClientRuntimeContext _Instance { get; } + + + public string Url { get => _Instance.Url; } + + public string ApplicationName { get => _Instance.ApplicationName; set => _Instance.ApplicationName = value; } + + public string ClientTag { get => _Instance.ClientTag; set => _Instance.ClientTag = value; } + + public bool DisableReturnValueCache { get => _Instance.DisableReturnValueCache; set => _Instance.DisableReturnValueCache = value; } + + public bool ValidateOnClient { get => _Instance.ValidateOnClient; set => _Instance.ValidateOnClient = value; } + + public System.Net.ICredentials Credentials { get => _Instance.Credentials; set => _Instance.Credentials = value; } + + public Microsoft.SharePoint.Client.WebRequestExecutorFactory WebRequestExecutorFactory { get => _Instance.WebRequestExecutorFactory; set => _Instance.WebRequestExecutorFactory = value; } + + public Microsoft.SharePoint.Client.ClientRequest PendingRequest { get => _Instance.PendingRequest; } + + public bool HasPendingRequest { get => _Instance.HasPendingRequest; } + + public object Tag { get => _Instance.Tag; set => _Instance.Tag = value; } + + public int RequestTimeout { get => _Instance.RequestTimeout; set => _Instance.RequestTimeout = value; } + + public System.Collections.Generic.Dictionary StaticObjects { get => _Instance.StaticObjects; } + + public System.Version ServerSchemaVersion { get => _Instance.ServerSchemaVersion; } + + public System.Version ServerLibraryVersion { get => _Instance.ServerLibraryVersion; } + + public System.Version RequestSchemaVersion { get => _Instance.RequestSchemaVersion; set => _Instance.RequestSchemaVersion = value; } + + public string TraceCorrelationId { get => _Instance.TraceCorrelationId; set => _Instance.TraceCorrelationId = value; } + + + + public virtual void ExecuteQuery() + { + _Instance.ExecuteQuery(); + } + + public virtual void RetryQuery(Microsoft.SharePoint.Client.ClientRequest request) + { + Microsoft.SharePoint.Client.ClientRequest request_ = request; + _Instance.RetryQuery(request_); + } + + public virtual System.Threading.Tasks.Task ExecuteQueryAsync() + { + var result_737681611 = _Instance.ExecuteQueryAsync(); + return result_737681611; + } + + public virtual System.Threading.Tasks.Task RetryQueryAsync(Microsoft.SharePoint.Client.ClientRequest request) + { + Microsoft.SharePoint.Client.ClientRequest request_ = request; + var result_1373930992 = _Instance.RetryQueryAsync(request_); + return result_1373930992; + } + + public T CastTo(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject obj) where T : Microsoft.SharePoint.Client.ClientObject + { + Microsoft.SharePoint.Client.ClientObject obj_ = _mapper.Map(obj); + var result_366781530 = _Instance.CastTo(obj_); + return result_366781530; + } + + public void AddQuery(Microsoft.SharePoint.Client.ClientAction query) + { + Microsoft.SharePoint.Client.ClientAction query_ = query; + _Instance.AddQuery(query_); + } + + public void AddQueryIdAndResultObject(long id, object obj) + { + long id_ = id; + object obj_ = obj; + _Instance.AddQueryIdAndResultObject(id_, obj_); + } + + public object ParseObjectFromJsonString(string json) + { + string json_ = json; + var result__1648501661 = _Instance.ParseObjectFromJsonString(json_); + return result__1648501661; + } + + public void AddClientTypeAssembly(System.Reflection.Assembly @assembly) + { + System.Reflection.Assembly @assembly_ = @assembly; + Microsoft.SharePoint.Client.ClientRuntimeContext.AddClientTypeAssembly(@assembly_); + } + + public void Load(T clientObject, params System.Linq.Expressions.Expression>[] retrievals) where T : Microsoft.SharePoint.Client.ClientObject + { + T clientObject_ = clientObject; + System.Linq.Expressions.Expression>[] retrievals_ = retrievals; + _Instance.Load(clientObject_, retrievals_); + } + + public System.Collections.Generic.IEnumerable LoadQuery(Microsoft.SharePoint.Client.ClientObjectCollection clientObjects) where T : Microsoft.SharePoint.Client.ClientObject + { + Microsoft.SharePoint.Client.ClientObjectCollection clientObjects_ = clientObjects; + var result_2035927496 = _Instance.LoadQuery(clientObjects_); + return result_2035927496; + } + + public System.Collections.Generic.IEnumerable LoadQuery(System.Linq.IQueryable clientObjects) where T : Microsoft.SharePoint.Client.ClientObject + { + System.Linq.IQueryable clientObjects_ = clientObjects; + var result_2035927496 = _Instance.LoadQuery(clientObjects_); + return result_2035927496; + } + + public void Dispose() + { + _Instance.Dispose(); + } + + + + public event System.EventHandler ExecutingWebRequest { add { _Instance.ExecutingWebRequest += value; } remove { _Instance.ExecutingWebRequest -= value; } } + + + + public ClientRuntimeContextProxy(Microsoft.SharePoint.Client.ClientRuntimeContext instance) + { + _Instance = instance; + + + _mapper = new MapperConfiguration(cfg => + { + cfg.CreateMap().ConstructUsing(instance_205293328 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy(instance_205293328)); + cfg.CreateMap().ConstructUsing(proxy1345472640 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy) proxy1345472640)._Instance); + cfg.CreateMap().ConstructUsing(instance_895746668 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy(instance_895746668)); + cfg.CreateMap().ConstructUsing(proxy1674261376 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy) proxy1674261376)._Instance); + cfg.CreateMap().ConstructUsing(instance_1283184912 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientContextProxy(instance_1283184912)); + cfg.CreateMap().ConstructUsing(proxy1267236400 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientContextProxy) proxy1267236400)._Instance); + }).CreateMapper(); + + } + + private readonly IMapper _mapper; + } +} +#nullable disable \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.WebProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.WebProxy.g.cs new file mode 100644 index 0000000..57fb26b --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/Microsoft.SharePoint.Client.WebProxy.g.cs @@ -0,0 +1,914 @@ +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; +using AutoMapper; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial class WebProxy : ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy, IWeb + { + public new Microsoft.SharePoint.Client.Web _Instance { get; } + public Microsoft.SharePoint.Client.ClientObject _InstanceBase { get; } + + + public string AccessRequestListUrl { get => _Instance.AccessRequestListUrl; } + + public string AccessRequestSiteDescription { get => _Instance.AccessRequestSiteDescription; } + + public Microsoft.SharePoint.Client.AlertCollection Alerts { get => _Instance.Alerts; } + + public bool AllowAutomaticASPXPageIndexing { get => _Instance.AllowAutomaticASPXPageIndexing; set => _Instance.AllowAutomaticASPXPageIndexing = value; } + + public bool AllowCreateDeclarativeWorkflowForCurrentUser { get => _Instance.AllowCreateDeclarativeWorkflowForCurrentUser; } + + public bool AllowDesignerForCurrentUser { get => _Instance.AllowDesignerForCurrentUser; } + + public bool AllowMasterPageEditingForCurrentUser { get => _Instance.AllowMasterPageEditingForCurrentUser; } + + public bool AllowRevertFromTemplateForCurrentUser { get => _Instance.AllowRevertFromTemplateForCurrentUser; } + + public bool AllowRssFeeds { get => _Instance.AllowRssFeeds; } + + public bool AllowSaveDeclarativeWorkflowAsTemplateForCurrentUser { get => _Instance.AllowSaveDeclarativeWorkflowAsTemplateForCurrentUser; } + + public bool AllowSavePublishDeclarativeWorkflowForCurrentUser { get => _Instance.AllowSavePublishDeclarativeWorkflowForCurrentUser; } + + public Microsoft.SharePoint.Client.PropertyValues AllProperties { get => _Instance.AllProperties; } + + public string AlternateCssUrl { get => _Instance.AlternateCssUrl; set => _Instance.AlternateCssUrl = value; } + + public System.Guid AppInstanceId { get => _Instance.AppInstanceId; } + + public Microsoft.SharePoint.Client.AppTileCollection AppTiles { get => _Instance.AppTiles; } + + public Microsoft.SharePoint.Client.Group AssociatedMemberGroup { get => _Instance.AssociatedMemberGroup; set => _Instance.AssociatedMemberGroup = value; } + + public Microsoft.SharePoint.Client.Group AssociatedOwnerGroup { get => _Instance.AssociatedOwnerGroup; set => _Instance.AssociatedOwnerGroup = value; } + + public Microsoft.SharePoint.Client.Group AssociatedVisitorGroup { get => _Instance.AssociatedVisitorGroup; set => _Instance.AssociatedVisitorGroup = value; } + + public Microsoft.SharePoint.Client.User Author { get => _Instance.Author; } + + public Microsoft.SharePoint.Client.ContentTypeCollection AvailableContentTypes { get => _Instance.AvailableContentTypes; } + + public Microsoft.SharePoint.Client.FieldCollection AvailableFields { get => _Instance.AvailableFields; } + + public Microsoft.SharePoint.Client.ModernizeHomepageResult CanModernizeHomepage { get => _Instance.CanModernizeHomepage; } + + public string ClassicWelcomePage { get => _Instance.ClassicWelcomePage; set => _Instance.ClassicWelcomePage = value; } + + public bool CommentsOnSitePagesDisabled { get => _Instance.CommentsOnSitePagesDisabled; set => _Instance.CommentsOnSitePagesDisabled = value; } + + public short Configuration { get => _Instance.Configuration; } + + public bool ContainsConfidentialInfo { get => _Instance.ContainsConfidentialInfo; set => _Instance.ContainsConfidentialInfo = value; } + + public Microsoft.SharePoint.Client.ContentTypeCollection ContentTypes { get => _Instance.ContentTypes; } + + public System.DateTime Created { get => _Instance.Created; } + + public Microsoft.SharePoint.Client.ChangeToken CurrentChangeToken { get => _Instance.CurrentChangeToken; } + + public Microsoft.SharePoint.Client.User CurrentUser { get => _Instance.CurrentUser; } + + public string CustomMasterUrl { get => _Instance.CustomMasterUrl; set => _Instance.CustomMasterUrl = value; } + + public bool CustomSiteActionsDisabled { get => _Instance.CustomSiteActionsDisabled; set => _Instance.CustomSiteActionsDisabled = value; } + + public Microsoft.SharePoint.Client.SPDataLeakagePreventionStatusInfo DataLeakagePreventionStatusInfo { get => _Instance.DataLeakagePreventionStatusInfo; } + + public string Description { get => _Instance.Description; set => _Instance.Description = value; } + + public Microsoft.SharePoint.Client.UserResource DescriptionResource { get => _Instance.DescriptionResource; } + + public System.Collections.Generic.IEnumerable DescriptionTranslations { get => _Instance.DescriptionTranslations; set => _Instance.DescriptionTranslations = value; } + + public string DesignerDownloadUrlForCurrentUser { get => _Instance.DesignerDownloadUrlForCurrentUser; } + + public System.Guid DesignPackageId { get => _Instance.DesignPackageId; set => _Instance.DesignPackageId = value; } + + public bool DisableAppViews { get => _Instance.DisableAppViews; set => _Instance.DisableAppViews = value; } + + public bool DisableFlows { get => _Instance.DisableFlows; set => _Instance.DisableFlows = value; } + + public bool DisableRecommendedItems { get => _Instance.DisableRecommendedItems; set => _Instance.DisableRecommendedItems = value; } + + public bool DocumentLibraryCalloutOfficeWebAppPreviewersDisabled { get => _Instance.DocumentLibraryCalloutOfficeWebAppPreviewersDisabled; } + + public Microsoft.SharePoint.Client.BasePermissions EffectiveBasePermissions { get => _Instance.EffectiveBasePermissions; } + + public bool EnableMinimalDownload { get => _Instance.EnableMinimalDownload; set => _Instance.EnableMinimalDownload = value; } + + public Microsoft.SharePoint.Client.EventReceiverDefinitionCollection EventReceivers { get => _Instance.EventReceivers; } + + public bool ExcludeFromOfflineClient { get => _Instance.ExcludeFromOfflineClient; set => _Instance.ExcludeFromOfflineClient = value; } + + public Microsoft.SharePoint.Client.FeatureCollection Features { get => _Instance.Features; } + + public Microsoft.SharePoint.Client.FieldCollection Fields { get => _Instance.Fields; } + + public Microsoft.SharePoint.Client.FolderCollection Folders { get => _Instance.Folders; } + + public Microsoft.SharePoint.Client.FooterVariantThemeType FooterEmphasis { get => _Instance.FooterEmphasis; set => _Instance.FooterEmphasis = value; } + + public bool FooterEnabled { get => _Instance.FooterEnabled; set => _Instance.FooterEnabled = value; } + + public Microsoft.SharePoint.Client.FooterLayoutType FooterLayout { get => _Instance.FooterLayout; set => _Instance.FooterLayout = value; } + + public bool HasWebTemplateExtension { get => _Instance.HasWebTemplateExtension; set => _Instance.HasWebTemplateExtension = value; } + + public Microsoft.SharePoint.Client.SPVariantThemeType HeaderEmphasis { get => _Instance.HeaderEmphasis; set => _Instance.HeaderEmphasis = value; } + + public Microsoft.SharePoint.Client.HeaderLayoutType HeaderLayout { get => _Instance.HeaderLayout; set => _Instance.HeaderLayout = value; } + + public bool HideTitleInHeader { get => _Instance.HideTitleInHeader; set => _Instance.HideTitleInHeader = value; } + + public bool HorizontalQuickLaunch { get => _Instance.HorizontalQuickLaunch; set => _Instance.HorizontalQuickLaunch = value; } + + public Microsoft.SharePoint.ClientSideComponent.HostedAppsManager HostedApps { get => _Instance.HostedApps; } + + public System.Guid Id { get => _Instance.Id; } + + public bool IsHomepageModernized { get => _Instance.IsHomepageModernized; } + + public bool IsMultilingual { get => _Instance.IsMultilingual; set => _Instance.IsMultilingual = value; } + + public bool IsProvisioningComplete { get => _Instance.IsProvisioningComplete; } + + public bool IsRevertHomepageLinkHidden { get => _Instance.IsRevertHomepageLinkHidden; set => _Instance.IsRevertHomepageLinkHidden = value; } + + public uint Language { get => _Instance.Language; } + + public System.DateTime LastItemModifiedDate { get => _Instance.LastItemModifiedDate; } + + public System.DateTime LastItemUserModifiedDate { get => _Instance.LastItemUserModifiedDate; } + + public Microsoft.SharePoint.Client.ListCollection Lists { get => _Instance.Lists; } + + public Microsoft.SharePoint.Client.ListTemplateCollection ListTemplates { get => _Instance.ListTemplates; } + + public Microsoft.SharePoint.Client.LogoAlignment LogoAlignment { get => _Instance.LogoAlignment; set => _Instance.LogoAlignment = value; } + + public string MasterUrl { get => _Instance.MasterUrl; set => _Instance.MasterUrl = value; } + + public bool MegaMenuEnabled { get => _Instance.MegaMenuEnabled; set => _Instance.MegaMenuEnabled = value; } + + public bool MembersCanShare { get => _Instance.MembersCanShare; set => _Instance.MembersCanShare = value; } + + public bool NavAudienceTargetingEnabled { get => _Instance.NavAudienceTargetingEnabled; set => _Instance.NavAudienceTargetingEnabled = value; } + + public Microsoft.SharePoint.Client.Navigation Navigation { get => _Instance.Navigation; } + + public bool NextStepsFirstRunEnabled { get => _Instance.NextStepsFirstRunEnabled; set => _Instance.NextStepsFirstRunEnabled = value; } + + public bool NoCrawl { get => _Instance.NoCrawl; set => _Instance.NoCrawl = value; } + + public bool NotificationsInOneDriveForBusinessEnabled { get => _Instance.NotificationsInOneDriveForBusinessEnabled; } + + public bool NotificationsInSharePointEnabled { get => _Instance.NotificationsInSharePointEnabled; } + + public bool ObjectCacheEnabled { get => _Instance.ObjectCacheEnabled; set => _Instance.ObjectCacheEnabled = value; } + + public bool OverwriteTranslationsOnChange { get => _Instance.OverwriteTranslationsOnChange; set => _Instance.OverwriteTranslationsOnChange = value; } + + public Microsoft.SharePoint.Client.WebInformation ParentWeb { get => _Instance.ParentWeb; } + + public Microsoft.SharePoint.Client.ResourcePath ResourcePath { get => _Instance.ResourcePath; } + + public bool PreviewFeaturesEnabled { get => _Instance.PreviewFeaturesEnabled; } + + public string PrimaryColor { get => _Instance.PrimaryColor; } + + public Microsoft.SharePoint.Client.PushNotificationSubscriberCollection PushNotificationSubscribers { get => _Instance.PushNotificationSubscribers; } + + public bool QuickLaunchEnabled { get => _Instance.QuickLaunchEnabled; set => _Instance.QuickLaunchEnabled = value; } + + public Microsoft.SharePoint.Client.RecycleBinItemCollection RecycleBin { get => _Instance.RecycleBin; } + + public bool RecycleBinEnabled { get => _Instance.RecycleBinEnabled; } + + public Microsoft.SharePoint.Client.RegionalSettings RegionalSettings { get => _Instance.RegionalSettings; } + + public string RequestAccessEmail { get => _Instance.RequestAccessEmail; set => _Instance.RequestAccessEmail = value; } + + public Microsoft.SharePoint.Client.RoleDefinitionCollection RoleDefinitions { get => _Instance.RoleDefinitions; } + + public Microsoft.SharePoint.Client.Folder RootFolder { get => _Instance.RootFolder; } + + public bool SaveSiteAsTemplateEnabled { get => _Instance.SaveSiteAsTemplateEnabled; set => _Instance.SaveSiteAsTemplateEnabled = value; } + + public Microsoft.SharePoint.Client.SearchBoxInNavBarType SearchBoxInNavBar { get => _Instance.SearchBoxInNavBar; set => _Instance.SearchBoxInNavBar = value; } + + public string SearchBoxPlaceholderText { get => _Instance.SearchBoxPlaceholderText; set => _Instance.SearchBoxPlaceholderText = value; } + + public Microsoft.SharePoint.Client.SearchScopeType SearchScope { get => _Instance.SearchScope; set => _Instance.SearchScope = value; } + + public Microsoft.SharePoint.Client.ResourcePath ServerRelativePath { get => _Instance.ServerRelativePath; } + + public string ServerRelativeUrl { get => _Instance.ServerRelativeUrl; set => _Instance.ServerRelativeUrl = value; } + + public bool ShowUrlStructureForCurrentUser { get => _Instance.ShowUrlStructureForCurrentUser; } + + public Microsoft.SharePoint.Marketplace.CorporateCuratedGallery.SiteCollectionCorporateCatalogAccessor SiteCollectionAppCatalog { get => _Instance.SiteCollectionAppCatalog; } + + public Microsoft.SharePoint.Client.GroupCollection SiteGroups { get => _Instance.SiteGroups; } + + public string SiteLogoDescription { get => _Instance.SiteLogoDescription; set => _Instance.SiteLogoDescription = value; } + + public string SiteLogoUrl { get => _Instance.SiteLogoUrl; set => _Instance.SiteLogoUrl = value; } + + public Microsoft.SharePoint.Client.List SiteUserInfoList { get => _Instance.SiteUserInfoList; } + + public Microsoft.SharePoint.Client.UserCollection SiteUsers { get => _Instance.SiteUsers; } + + public System.Collections.Generic.IEnumerable SupportedUILanguageIds { get => _Instance.SupportedUILanguageIds; set => _Instance.SupportedUILanguageIds = value; } + + public bool SyndicationEnabled { get => _Instance.SyndicationEnabled; set => _Instance.SyndicationEnabled = value; } + + public Microsoft.SharePoint.Client.SharingState TenantAdminMembersCanShare { get => _Instance.TenantAdminMembersCanShare; } + + public Microsoft.SharePoint.Marketplace.CorporateCuratedGallery.TenantCorporateCatalogAccessor TenantAppCatalog { get => _Instance.TenantAppCatalog; } + + public bool TenantTagPolicyEnabled { get => _Instance.TenantTagPolicyEnabled; } + + public string ThemedCssFolderUrl { get => _Instance.ThemedCssFolderUrl; set => _Instance.ThemedCssFolderUrl = value; } + + public Microsoft.SharePoint.Client.ThemeInfo ThemeInfo { get => _Instance.ThemeInfo; } + + public bool ThirdPartyMdmEnabled { get => _Instance.ThirdPartyMdmEnabled; } + + public string Title { get => _Instance.Title; set => _Instance.Title = value; } + + public Microsoft.SharePoint.Client.UserResource TitleResource { get => _Instance.TitleResource; } + + public System.Collections.Generic.IEnumerable TitleTranslations { get => _Instance.TitleTranslations; set => _Instance.TitleTranslations = value; } + + public bool TreeViewEnabled { get => _Instance.TreeViewEnabled; set => _Instance.TreeViewEnabled = value; } + + public int UIVersion { get => _Instance.UIVersion; set => _Instance.UIVersion = value; } + + public bool UIVersionConfigurationEnabled { get => _Instance.UIVersionConfigurationEnabled; set => _Instance.UIVersionConfigurationEnabled = value; } + + public string Url { get => _Instance.Url; } + + public bool UseAccessRequestDefault { get => _Instance.UseAccessRequestDefault; } + + public Microsoft.SharePoint.Client.UserCustomActionCollection UserCustomActions { get => _Instance.UserCustomActions; } + + public Microsoft.SharePoint.Client.WebCollection Webs { get => _Instance.Webs; } + + public string WebTemplate { get => _Instance.WebTemplate; } + + public string WebTemplateConfiguration { get => _Instance.WebTemplateConfiguration; } + + public bool WebTemplatesGalleryFirstRunEnabled { get => _Instance.WebTemplatesGalleryFirstRunEnabled; set => _Instance.WebTemplatesGalleryFirstRunEnabled = value; } + + public string WelcomePage { get => _Instance.WelcomePage; } + + public Microsoft.SharePoint.Client.Workflow.WorkflowAssociationCollection WorkflowAssociations { get => _Instance.WorkflowAssociations; } + + public Microsoft.SharePoint.Client.Workflow.WorkflowTemplateCollection WorkflowTemplates { get => _Instance.WorkflowTemplates; } + + + + public System.Uri WebUrlFromPageUrlDirect(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext context, System.Uri pageFullUrl) + { + Microsoft.SharePoint.Client.ClientContext context_ = _mapper.Map(context); + System.Uri pageFullUrl_ = pageFullUrl; + var result__258107370 = Microsoft.SharePoint.Client.Web.WebUrlFromPageUrlDirect(context_, pageFullUrl_); + return result__258107370; + } + + public System.Uri WebUrlFromFolderUrlDirect(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext context, System.Uri folderFullUrl) + { + Microsoft.SharePoint.Client.ClientContext context_ = _mapper.Map(context); + System.Uri folderFullUrl_ = folderFullUrl; + var result_21992317 = Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect(context_, folderFullUrl_); + return result_21992317; + } + + public Microsoft.SharePoint.Client.ClientResult DoesUserHavePermissions(Microsoft.SharePoint.Client.BasePermissions permissionMask) + { + Microsoft.SharePoint.Client.BasePermissions permissionMask_ = permissionMask; + var result_563212462 = _Instance.DoesUserHavePermissions(permissionMask_); + return result_563212462; + } + + public Microsoft.SharePoint.Client.ClientResult GetUserEffectivePermissions(string userName) + { + string userName_ = userName; + var result__615383406 = _Instance.GetUserEffectivePermissions(userName_); + return result__615383406; + } + + public void CreateDefaultAssociatedGroups(string userLogin, string userLogin2, string groupNameSeed) + { + string userLogin_ = userLogin; + string userLogin2_ = userLogin2; + string groupNameSeed_ = groupNameSeed; + _Instance.CreateDefaultAssociatedGroups(userLogin_, userLogin2_, groupNameSeed_); + } + + public Microsoft.SharePoint.Client.User GetUserById(int userId) + { + int userId_ = userId; + var result__963170767 = _Instance.GetUserById(userId_); + return result__963170767; + } + + public Microsoft.SharePoint.Client.ClientResult EnsureTenantAppCatalog(string callerId) + { + string callerId_ = callerId; + var result__1044639826 = _Instance.EnsureTenantAppCatalog(callerId_); + return result__1044639826; + } + + public Microsoft.SharePoint.ClientSideComponent.StorageEntity GetStorageEntity(string key) + { + string key_ = key; + var result__1529029872 = _Instance.GetStorageEntity(key_); + return result__1529029872; + } + + public void SetStorageEntity(string key, string value, string description, string comments) + { + string key_ = key; + string value_ = value; + string description_ = description; + string comments_ = comments; + _Instance.SetStorageEntity(key_, value_, description_, comments_); + } + + public void RemoveStorageEntity(string key) + { + string key_ = key; + _Instance.RemoveStorageEntity(key_); + } + + public Microsoft.SharePoint.Client.SharingResult ShareObject(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, string peoplePickerInput, string roleValue, int groupId, bool propagateAcl, bool sendEmail, bool includeAnonymousLinkInEmail, string emailSubject, string emailBody, bool useSimplifiedRoles) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + string peoplePickerInput_ = peoplePickerInput; + string roleValue_ = roleValue; + int groupId_ = groupId; + bool propagateAcl_ = propagateAcl; + bool sendEmail_ = sendEmail; + bool includeAnonymousLinkInEmail_ = includeAnonymousLinkInEmail; + string emailSubject_ = emailSubject; + string emailBody_ = emailBody; + bool useSimplifiedRoles_ = useSimplifiedRoles; + var result_816157054 = Microsoft.SharePoint.Client.Web.ShareObject(context_, url_, peoplePickerInput_, roleValue_, groupId_, propagateAcl_, sendEmail_, includeAnonymousLinkInEmail_, emailSubject_, emailBody_, useSimplifiedRoles_); + return result_816157054; + } + + public Microsoft.SharePoint.Client.SharingResult ForwardObjectLink(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, string peoplePickerInput, string emailSubject, string emailBody) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + string peoplePickerInput_ = peoplePickerInput; + string emailSubject_ = emailSubject; + string emailBody_ = emailBody; + var result__1822800612 = Microsoft.SharePoint.Client.Web.ForwardObjectLink(context_, url_, peoplePickerInput_, emailSubject_, emailBody_); + return result__1822800612; + } + + public Microsoft.SharePoint.Client.SharingResult UnshareObject(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + var result__823224569 = Microsoft.SharePoint.Client.Web.UnshareObject(context_, url_); + return result__823224569; + } + + public Microsoft.SharePoint.Client.ObjectSharingSettings GetObjectSharingSettings(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string objectUrl, int groupId, bool useSimplifiedRoles) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string objectUrl_ = objectUrl; + int groupId_ = groupId; + bool useSimplifiedRoles_ = useSimplifiedRoles; + var result__679475674 = Microsoft.SharePoint.Client.Web.GetObjectSharingSettings(context_, objectUrl_, groupId_, useSimplifiedRoles_); + return result__679475674; + } + + public Microsoft.SharePoint.Client.ClientResult CreateAnonymousLink(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + bool isEditLink_ = isEditLink; + var result__820192309 = Microsoft.SharePoint.Client.Web.CreateAnonymousLink(context_, url_, isEditLink_); + return result__820192309; + } + + public Microsoft.SharePoint.Client.ClientResult CreateAnonymousLinkWithExpiration(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink, string expirationString) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + bool isEditLink_ = isEditLink; + string expirationString_ = expirationString; + var result__1044574026 = Microsoft.SharePoint.Client.Web.CreateAnonymousLinkWithExpiration(context_, url_, isEditLink_, expirationString_); + return result__1044574026; + } + + public void DeleteAllAnonymousLinksForObject(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + Microsoft.SharePoint.Client.Web.DeleteAllAnonymousLinksForObject(context_, url_); + } + + public void DeleteAnonymousLinkForObject(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink, bool removeAssociatedSharingLinkGroup) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + bool isEditLink_ = isEditLink; + bool removeAssociatedSharingLinkGroup_ = removeAssociatedSharingLinkGroup; + Microsoft.SharePoint.Client.Web.DeleteAnonymousLinkForObject(context_, url_, isEditLink_, removeAssociatedSharingLinkGroup_); + } + + public Microsoft.SharePoint.Client.ClientResult CreateOrganizationSharingLink(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + bool isEditLink_ = isEditLink; + var result_2070260011 = Microsoft.SharePoint.Client.Web.CreateOrganizationSharingLink(context_, url_, isEditLink_); + return result_2070260011; + } + + public void DestroyOrganizationSharingLink(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink, bool removeAssociatedSharingLinkGroup) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string url_ = url; + bool isEditLink_ = isEditLink; + bool removeAssociatedSharingLinkGroup_ = removeAssociatedSharingLinkGroup; + Microsoft.SharePoint.Client.Web.DestroyOrganizationSharingLink(context_, url_, isEditLink_, removeAssociatedSharingLinkGroup_); + } + + public Microsoft.SharePoint.Client.ClientResult GetSharingLinkKind(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string fileUrl) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string fileUrl_ = fileUrl; + var result_654626020 = Microsoft.SharePoint.Client.Web.GetSharingLinkKind(context_, fileUrl_); + return result_654626020; + } + + public Microsoft.SharePoint.Client.ClientResult GetSharingLinkData(string linkUrl) + { + string linkUrl_ = linkUrl; + var result__2107757018 = _Instance.GetSharingLinkData(linkUrl_); + return result__2107757018; + } + + public Microsoft.SharePoint.Client.ClientResult MapToIcon(string fileName, string progId, Microsoft.SharePoint.Client.Utilities.IconSize size) + { + string fileName_ = fileName; + string progId_ = progId; + Microsoft.SharePoint.Client.Utilities.IconSize size_ = size; + var result_384589064 = _Instance.MapToIcon(fileName_, progId_, size_); + return result_384589064; + } + + public Microsoft.SharePoint.Client.ClientResult GetWebUrlFromPageUrl(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string pageFullUrl) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string pageFullUrl_ = pageFullUrl; + var result__907059837 = Microsoft.SharePoint.Client.Web.GetWebUrlFromPageUrl(context_, pageFullUrl_); + return result__907059837; + } + + public Microsoft.SharePoint.Client.PushNotificationSubscriber RegisterPushNotificationSubscriber(System.Guid deviceAppInstanceId, string serviceToken) + { + System.Guid deviceAppInstanceId_ = deviceAppInstanceId; + string serviceToken_ = serviceToken; + var result__117534630 = _Instance.RegisterPushNotificationSubscriber(deviceAppInstanceId_, serviceToken_); + return result__117534630; + } + + public void UnregisterPushNotificationSubscriber(System.Guid deviceAppInstanceId) + { + System.Guid deviceAppInstanceId_ = deviceAppInstanceId; + _Instance.UnregisterPushNotificationSubscriber(deviceAppInstanceId_); + } + + public Microsoft.SharePoint.Client.PushNotificationSubscriberCollection GetPushNotificationSubscribersByArgs(string customArgs) + { + string customArgs_ = customArgs; + var result_144086076 = _Instance.GetPushNotificationSubscribersByArgs(customArgs_); + return result_144086076; + } + + public Microsoft.SharePoint.Client.PushNotificationSubscriberCollection GetPushNotificationSubscribersByUser(string userName) + { + string userName_ = userName; + var result__1280834962 = _Instance.GetPushNotificationSubscribersByUser(userName_); + return result__1280834962; + } + + public Microsoft.SharePoint.Client.ClientResult DoesPushNotificationSubscriberExist(System.Guid deviceAppInstanceId) + { + System.Guid deviceAppInstanceId_ = deviceAppInstanceId; + var result__1309404561 = _Instance.DoesPushNotificationSubscriberExist(deviceAppInstanceId_); + return result__1309404561; + } + + public Microsoft.SharePoint.Client.PushNotificationSubscriber GetPushNotificationSubscriber(System.Guid deviceAppInstanceId) + { + System.Guid deviceAppInstanceId_ = deviceAppInstanceId; + var result_1696633571 = _Instance.GetPushNotificationSubscriber(deviceAppInstanceId_); + return result_1696633571; + } + + public Microsoft.SharePoint.Client.RecycleBinItemCollection GetRecycleBinItems(string pagingInfo, int rowLimit, bool isAscending, Microsoft.SharePoint.Client.RecycleBinOrderBy orderBy, Microsoft.SharePoint.Client.RecycleBinItemState itemState) + { + string pagingInfo_ = pagingInfo; + int rowLimit_ = rowLimit; + bool isAscending_ = isAscending; + Microsoft.SharePoint.Client.RecycleBinOrderBy orderBy_ = orderBy; + Microsoft.SharePoint.Client.RecycleBinItemState itemState_ = itemState; + var result_694026616 = _Instance.GetRecycleBinItems(pagingInfo_, rowLimit_, isAscending_, orderBy_, itemState_); + return result_694026616; + } + + public Microsoft.SharePoint.Client.RecycleBinItemCollection GetRecycleBinItemsByQueryInfo(Microsoft.SharePoint.Client.RecycleBinQueryInformation queryInfo) + { + Microsoft.SharePoint.Client.RecycleBinQueryInformation queryInfo_ = queryInfo; + var result__1467955603 = _Instance.GetRecycleBinItemsByQueryInfo(queryInfo_); + return result__1467955603; + } + + public Microsoft.SharePoint.Client.ChangeCollection GetChanges(Microsoft.SharePoint.Client.ChangeQuery query) + { + Microsoft.SharePoint.Client.ChangeQuery query_ = query; + var result_536201347 = _Instance.GetChanges(query_); + return result_536201347; + } + + public Microsoft.SharePoint.Client.List GetList(string strUrl) + { + string strUrl_ = strUrl; + var result_1483657030 = _Instance.GetList(strUrl_); + return result_1483657030; + } + + public Microsoft.SharePoint.Client.List GetListUsingPath(Microsoft.SharePoint.Client.ResourcePath path) + { + Microsoft.SharePoint.Client.ResourcePath path_ = path; + var result__2113955437 = _Instance.GetListUsingPath(path_); + return result__2113955437; + } + + public Microsoft.SharePoint.Client.ListItem GetListItem(string strUrl) + { + string strUrl_ = strUrl; + var result_101515089 = _Instance.GetListItem(strUrl_); + return result_101515089; + } + + public Microsoft.SharePoint.Client.ListItem GetListItemUsingPath(Microsoft.SharePoint.Client.ResourcePath path) + { + Microsoft.SharePoint.Client.ResourcePath path_ = path; + var result__577192176 = _Instance.GetListItemUsingPath(path_); + return result__577192176; + } + + public Microsoft.SharePoint.Client.ListItem GetListItemByResourceId(string resourceId) + { + string resourceId_ = resourceId; + var result_569057021 = _Instance.GetListItemByResourceId(resourceId_); + return result_569057021; + } + + public Microsoft.BusinessData.MetadataModel.Entity GetEntity(string @namespace, string name) + { + string @namespace_ = @namespace; + string name_ = name; + var result_401289025 = _Instance.GetEntity(@namespace_, name_); + return result_401289025; + } + + public Microsoft.BusinessData.MetadataModel.AppBdcCatalog GetAppBdcCatalogForAppInstance(System.Guid appInstanceId) + { + System.Guid appInstanceId_ = appInstanceId; + var result__1179378574 = _Instance.GetAppBdcCatalogForAppInstance(appInstanceId_); + return result__1179378574; + } + + public Microsoft.BusinessData.MetadataModel.AppBdcCatalog GetAppBdcCatalog() + { + var result__1128404427 = _Instance.GetAppBdcCatalog(); + return result__1128404427; + } + + public Microsoft.SharePoint.Client.WebCollection GetSubwebsForCurrentUser(Microsoft.SharePoint.Client.SubwebQuery query) + { + Microsoft.SharePoint.Client.SubwebQuery query_ = query; + var result__34039800 = _Instance.GetSubwebsForCurrentUser(query_); + return result__34039800; + } + + public Microsoft.SharePoint.Client.ClientResult GetSPAppContextAsStream() + { + var result_127789125 = _Instance.GetSPAppContextAsStream(); + return result_127789125; + } + + public Microsoft.SharePoint.Client.WebTemplateCollection GetAvailableWebTemplates(uint lcid, bool doIncludeCrossLanguage) + { + uint lcid_ = lcid; + bool doIncludeCrossLanguage_ = doIncludeCrossLanguage; + var result__1052443476 = _Instance.GetAvailableWebTemplates(lcid_, doIncludeCrossLanguage_); + return result__1052443476; + } + + public Microsoft.SharePoint.Client.List GetCatalog(int typeCatalog) + { + int typeCatalog_ = typeCatalog; + var result__1458409307 = _Instance.GetCatalog(typeCatalog_); + return result__1458409307; + } + + public Microsoft.SharePoint.Client.View GetViewFromUrl(string listUrl) + { + string listUrl_ = listUrl; + var result_1074039380 = _Instance.GetViewFromUrl(listUrl_); + return result_1074039380; + } + + public Microsoft.SharePoint.Client.View GetViewFromPath(Microsoft.SharePoint.Client.ResourcePath listPath) + { + Microsoft.SharePoint.Client.ResourcePath listPath_ = listPath; + var result_1126862484 = _Instance.GetViewFromPath(listPath_); + return result_1126862484; + } + + public Microsoft.SharePoint.Client.File GetFileByServerRelativeUrl(string serverRelativeUrl) + { + string serverRelativeUrl_ = serverRelativeUrl; + var result__979182843 = _Instance.GetFileByServerRelativeUrl(serverRelativeUrl_); + return result__979182843; + } + + public Microsoft.SharePoint.Client.File GetFileByServerRelativePath(Microsoft.SharePoint.Client.ResourcePath serverRelativePath) + { + Microsoft.SharePoint.Client.ResourcePath serverRelativePath_ = serverRelativePath; + var result_1456830503 = _Instance.GetFileByServerRelativePath(serverRelativePath_); + return result_1456830503; + } + + public System.Collections.Generic.IList GetDocumentLibraries(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string webFullUrl) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string webFullUrl_ = webFullUrl; + var result_2078170246 = Microsoft.SharePoint.Client.Web.GetDocumentLibraries(context_, webFullUrl_); + return result_2078170246; + } + + public System.Collections.Generic.IList GetDocumentAndMediaLibraries(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string webFullUrl, bool includePageLibraries) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string webFullUrl_ = webFullUrl; + bool includePageLibraries_ = includePageLibraries; + var result__431075153 = Microsoft.SharePoint.Client.Web.GetDocumentAndMediaLibraries(context_, webFullUrl_, includePageLibraries_); + return result__431075153; + } + + public Microsoft.SharePoint.Client.ClientResult DefaultDocumentLibraryUrl(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string webUrl) + { + Microsoft.SharePoint.Client.ClientRuntimeContext context_ = _mapper.Map(context); + string webUrl_ = webUrl; + var result_1125717726 = Microsoft.SharePoint.Client.Web.DefaultDocumentLibraryUrl(context_, webUrl_); + return result_1125717726; + } + + public Microsoft.SharePoint.Client.List DefaultDocumentLibrary() + { + var result_69743263 = _Instance.DefaultDocumentLibrary(); + return result_69743263; + } + + public Microsoft.SharePoint.Client.File GetFileById(System.Guid uniqueId) + { + System.Guid uniqueId_ = uniqueId; + var result__223228596 = _Instance.GetFileById(uniqueId_); + return result__223228596; + } + + public Microsoft.SharePoint.Client.Folder GetFolderById(System.Guid uniqueId) + { + System.Guid uniqueId_ = uniqueId; + var result__2111623002 = _Instance.GetFolderById(uniqueId_); + return result__2111623002; + } + + public Microsoft.SharePoint.Client.File GetFileByLinkingUrl(string linkingUrl) + { + string linkingUrl_ = linkingUrl; + var result__104450524 = _Instance.GetFileByLinkingUrl(linkingUrl_); + return result__104450524; + } + + public Microsoft.SharePoint.Client.File GetFileByGuestUrl(string guestUrl) + { + string guestUrl_ = guestUrl; + var result_1819257688 = _Instance.GetFileByGuestUrl(guestUrl_); + return result_1819257688; + } + + public Microsoft.SharePoint.Client.File GetFileByGuestUrlEnsureAccess(string guestUrl, bool ensureAccess) + { + string guestUrl_ = guestUrl; + bool ensureAccess_ = ensureAccess; + var result__323239372 = _Instance.GetFileByGuestUrlEnsureAccess(guestUrl_, ensureAccess_); + return result__323239372; + } + + public Microsoft.SharePoint.Client.File GetFileByWOPIFrameUrl(string wopiFrameUrl) + { + string wopiFrameUrl_ = wopiFrameUrl; + var result_1184208158 = _Instance.GetFileByWOPIFrameUrl(wopiFrameUrl_); + return result_1184208158; + } + + public Microsoft.SharePoint.Client.File GetFileByUrl(string fileUrl) + { + string fileUrl_ = fileUrl; + var result__84028506 = _Instance.GetFileByUrl(fileUrl_); + return result__84028506; + } + + public Microsoft.SharePoint.Client.Folder GetFolderByServerRelativeUrl(string serverRelativeUrl) + { + string serverRelativeUrl_ = serverRelativeUrl; + var result_1556909417 = _Instance.GetFolderByServerRelativeUrl(serverRelativeUrl_); + return result_1556909417; + } + + public Microsoft.SharePoint.Client.Folder GetFolderByServerRelativePath(Microsoft.SharePoint.Client.ResourcePath serverRelativePath) + { + Microsoft.SharePoint.Client.ResourcePath serverRelativePath_ = serverRelativePath; + var result__1812606997 = _Instance.GetFolderByServerRelativePath(serverRelativePath_); + return result__1812606997; + } + + public void ApplyWebTemplate(string webTemplate) + { + string webTemplate_ = webTemplate; + _Instance.ApplyWebTemplate(webTemplate_); + } + + public void DeleteObject() + { + _Instance.DeleteObject(); + } + + public void Update() + { + _Instance.Update(); + } + + public Microsoft.SharePoint.Client.ClientResult PageContextInfo(bool includeODBSettings, bool emitNavigationInfo) + { + bool includeODBSettings_ = includeODBSettings; + bool emitNavigationInfo_ = emitNavigationInfo; + var result_1488981072 = _Instance.PageContextInfo(includeODBSettings_, emitNavigationInfo_); + return result_1488981072; + } + + public Microsoft.SharePoint.Client.ClientResult PageContextCore() + { + var result_769613763 = _Instance.PageContextCore(); + return result_769613763; + } + + public Microsoft.SharePoint.Client.AppInstance GetAppInstanceById(System.Guid appInstanceId) + { + System.Guid appInstanceId_ = appInstanceId; + var result__860011802 = _Instance.GetAppInstanceById(appInstanceId_); + return result__860011802; + } + + public Microsoft.SharePoint.Client.ClientObjectList GetAppInstancesByProductId(System.Guid productId) + { + System.Guid productId_ = productId; + var result__1349849408 = _Instance.GetAppInstancesByProductId(productId_); + return result__1349849408; + } + + public Microsoft.SharePoint.Client.AppInstance LoadAndInstallAppInSpecifiedLocale(System.IO.Stream appPackageStream, int installationLocaleLCID) + { + System.IO.Stream appPackageStream_ = appPackageStream; + int installationLocaleLCID_ = installationLocaleLCID; + var result__860277814 = _Instance.LoadAndInstallAppInSpecifiedLocale(appPackageStream_, installationLocaleLCID_); + return result__860277814; + } + + public Microsoft.SharePoint.Client.AppInstance LoadApp(System.IO.Stream appPackageStream, int installationLocaleLCID) + { + System.IO.Stream appPackageStream_ = appPackageStream; + int installationLocaleLCID_ = installationLocaleLCID; + var result__1043610289 = _Instance.LoadApp(appPackageStream_, installationLocaleLCID_); + return result__1043610289; + } + + public Microsoft.SharePoint.Client.ClientResult AddPlaceholderUser(string listId, string placeholderText) + { + string listId_ = listId; + string placeholderText_ = placeholderText; + var result__256231457 = _Instance.AddPlaceholderUser(listId_, placeholderText_); + return result__256231457; + } + + public Microsoft.SharePoint.Client.AppInstance LoadAndInstallApp(System.IO.Stream appPackageStream) + { + System.IO.Stream appPackageStream_ = appPackageStream; + var result__1506697459 = _Instance.LoadAndInstallApp(appPackageStream_); + return result__1506697459; + } + + public void SetAccessRequestSiteDescriptionAndUpdate(string description) + { + string description_ = description; + _Instance.SetAccessRequestSiteDescriptionAndUpdate(description_); + } + + public void SetUseAccessRequestDefaultAndUpdate(bool useAccessRequestDefault) + { + bool useAccessRequestDefault_ = useAccessRequestDefault; + _Instance.SetUseAccessRequestDefaultAndUpdate(useAccessRequestDefault_); + } + + public void IncrementSiteClientTag() + { + _Instance.IncrementSiteClientTag(); + } + + public void AddSupportedUILanguage(int lcid) + { + int lcid_ = lcid; + _Instance.AddSupportedUILanguage(lcid_); + } + + public void RemoveSupportedUILanguage(int lcid) + { + int lcid_ = lcid; + _Instance.RemoveSupportedUILanguage(lcid_); + } + + public Microsoft.SharePoint.Client.User EnsureUser(string logonName) + { + string logonName_ = logonName; + var result_1853915411 = _Instance.EnsureUser(logonName_); + return result_1853915411; + } + + public Microsoft.SharePoint.Client.User EnsureUserByObjectId(System.Guid objectId, System.Guid tenantId, Microsoft.SharePoint.Client.Utilities.PrincipalType principalType) + { + System.Guid objectId_ = objectId; + System.Guid tenantId_ = tenantId; + Microsoft.SharePoint.Client.Utilities.PrincipalType principalType_ = principalType; + var result__1490083264 = _Instance.EnsureUserByObjectId(objectId_, tenantId_, principalType_); + return result__1490083264; + } + + public void ApplyTheme(string colorPaletteUrl, string fontSchemeUrl, string backgroundImageUrl, bool shareGenerated) + { + string colorPaletteUrl_ = colorPaletteUrl; + string fontSchemeUrl_ = fontSchemeUrl; + string backgroundImageUrl_ = backgroundImageUrl; + bool shareGenerated_ = shareGenerated; + _Instance.ApplyTheme(colorPaletteUrl_, fontSchemeUrl_, backgroundImageUrl_, shareGenerated_); + } + + + + + + public WebProxy(Microsoft.SharePoint.Client.Web instance) : base(instance) + { + _Instance = instance; + _InstanceBase = instance; + + _mapper = new MapperConfiguration(cfg => + { + cfg.CreateMap().ConstructUsing(instance_205293328 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy(instance_205293328)); + cfg.CreateMap().ConstructUsing(proxy1345472640 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientRuntimeContextProxy) proxy1345472640)._Instance); + cfg.CreateMap().ConstructUsing(instance_895746668 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy(instance_895746668)); + cfg.CreateMap().ConstructUsing(proxy1674261376 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientObjectProxy) proxy1674261376)._Instance); + cfg.CreateMap().ConstructUsing(instance_1283184912 => new ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientContextProxy(instance_1283184912)); + cfg.CreateMap().ConstructUsing(proxy1267236400 => ((ProxyInterfaceSourceGeneratorTests.Source.PnP.ClientContextProxy) proxy1267236400)._Instance); + }).CreateMapper(); + + } + + private readonly IMapper _mapper; + } +} +#nullable disable \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonProxy.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonProxy.g.cs index 0b8ff64..07b69b6 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonProxy.g.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PersonProxy.g.cs @@ -116,8 +116,8 @@ namespace ProxyInterfaceSourceGeneratorTests.Source _mapper = new MapperConfiguration(cfg => { - cfg.CreateMap().ConstructUsing(instance => new ProxyInterfaceSourceGeneratorTests.Source.HumanProxy(instance)); - cfg.CreateMap().ConstructUsing(proxy => ((ProxyInterfaceSourceGeneratorTests.Source.HumanProxy) proxy)._Instance); + cfg.CreateMap().ConstructUsing(instance_1903550791 => new ProxyInterfaceSourceGeneratorTests.Source.HumanProxy(instance_1903550791)); + cfg.CreateMap().ConstructUsing(proxy1075308949 => ((ProxyInterfaceSourceGeneratorTests.Source.HumanProxy) proxy1075308949)._Instance); }).CreateMapper(); } diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs new file mode 100644 index 0000000..b5337cf --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs @@ -0,0 +1,38 @@ +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial interface IClientContext + { + ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb Web { get; } + + Microsoft.SharePoint.Client.Site Site { get; } + + Microsoft.SharePoint.Client.RequestResources RequestResources { get; } + + System.Version ServerVersion { get; } + + + + Microsoft.SharePoint.Client.FormDigestInfo GetFormDigestDirect(); + + void ExecuteQuery(); + + System.Threading.Tasks.Task ExecuteQueryAsync(); + + + + + } +} +#nullable disable \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs new file mode 100644 index 0000000..0ff1b17 --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs @@ -0,0 +1,50 @@ +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial interface IClientObject + { + ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext Context { get; } + + object Tag { get; set; } + + Microsoft.SharePoint.Client.ObjectPath Path { get; } + + string ObjectVersion { get; set; } + + bool? ServerObjectIsNull { get; } + + ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject TypedObject { get; } + + + + void FromJson(Microsoft.SharePoint.Client.JsonReader reader); + + bool CustomFromJson(Microsoft.SharePoint.Client.JsonReader reader); + + void Retrieve(); + + void Retrieve(params string[] propertyNames); + + void RefreshLoad(); + + bool IsPropertyAvailable(string propertyName); + + bool IsObjectPropertyInstantiated(string propertyName); + + + + + } +} +#nullable disable \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs new file mode 100644 index 0000000..bb25571 --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs @@ -0,0 +1,84 @@ +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial interface IClientRuntimeContext + { + string Url { get; } + + string ApplicationName { get; set; } + + string ClientTag { get; set; } + + bool DisableReturnValueCache { get; set; } + + bool ValidateOnClient { get; set; } + + System.Net.ICredentials Credentials { get; set; } + + Microsoft.SharePoint.Client.WebRequestExecutorFactory WebRequestExecutorFactory { get; set; } + + Microsoft.SharePoint.Client.ClientRequest PendingRequest { get; } + + bool HasPendingRequest { get; } + + object Tag { get; set; } + + int RequestTimeout { get; set; } + + System.Collections.Generic.Dictionary StaticObjects { get; } + + System.Version ServerSchemaVersion { get; } + + System.Version ServerLibraryVersion { get; } + + System.Version RequestSchemaVersion { get; set; } + + string TraceCorrelationId { get; set; } + + + + void ExecuteQuery(); + + void RetryQuery(Microsoft.SharePoint.Client.ClientRequest request); + + System.Threading.Tasks.Task ExecuteQueryAsync(); + + System.Threading.Tasks.Task RetryQueryAsync(Microsoft.SharePoint.Client.ClientRequest request); + + T CastTo(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject obj) where T : Microsoft.SharePoint.Client.ClientObject; + + void AddQuery(Microsoft.SharePoint.Client.ClientAction query); + + void AddQueryIdAndResultObject(long id, object obj); + + object ParseObjectFromJsonString(string json); + + void AddClientTypeAssembly(System.Reflection.Assembly @assembly); + + void Load(T clientObject, params System.Linq.Expressions.Expression>[] retrievals) where T : Microsoft.SharePoint.Client.ClientObject; + + System.Collections.Generic.IEnumerable LoadQuery(Microsoft.SharePoint.Client.ClientObjectCollection clientObjects) where T : Microsoft.SharePoint.Client.ClientObject; + + System.Collections.Generic.IEnumerable LoadQuery(System.Linq.IQueryable clientObjects) where T : Microsoft.SharePoint.Client.ClientObject; + + void Dispose(); + + + + event System.EventHandler ExecutingWebRequest; + + + } +} +#nullable disable \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs new file mode 100644 index 0000000..6fac28c --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Destination/ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs @@ -0,0 +1,444 @@ +//---------------------------------------------------------------------------------------- +// +// This code was generated by https://github.com/StefH/ProxyInterfaceSourceGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//---------------------------------------------------------------------------------------- + +#nullable enable +using System; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial interface IWeb + { + string AccessRequestListUrl { get; } + + string AccessRequestSiteDescription { get; } + + Microsoft.SharePoint.Client.AlertCollection Alerts { get; } + + bool AllowAutomaticASPXPageIndexing { get; set; } + + bool AllowCreateDeclarativeWorkflowForCurrentUser { get; } + + bool AllowDesignerForCurrentUser { get; } + + bool AllowMasterPageEditingForCurrentUser { get; } + + bool AllowRevertFromTemplateForCurrentUser { get; } + + bool AllowRssFeeds { get; } + + bool AllowSaveDeclarativeWorkflowAsTemplateForCurrentUser { get; } + + bool AllowSavePublishDeclarativeWorkflowForCurrentUser { get; } + + Microsoft.SharePoint.Client.PropertyValues AllProperties { get; } + + string AlternateCssUrl { get; set; } + + System.Guid AppInstanceId { get; } + + Microsoft.SharePoint.Client.AppTileCollection AppTiles { get; } + + Microsoft.SharePoint.Client.Group AssociatedMemberGroup { get; set; } + + Microsoft.SharePoint.Client.Group AssociatedOwnerGroup { get; set; } + + Microsoft.SharePoint.Client.Group AssociatedVisitorGroup { get; set; } + + Microsoft.SharePoint.Client.User Author { get; } + + Microsoft.SharePoint.Client.ContentTypeCollection AvailableContentTypes { get; } + + Microsoft.SharePoint.Client.FieldCollection AvailableFields { get; } + + Microsoft.SharePoint.Client.ModernizeHomepageResult CanModernizeHomepage { get; } + + string ClassicWelcomePage { get; set; } + + bool CommentsOnSitePagesDisabled { get; set; } + + short Configuration { get; } + + bool ContainsConfidentialInfo { get; set; } + + Microsoft.SharePoint.Client.ContentTypeCollection ContentTypes { get; } + + System.DateTime Created { get; } + + Microsoft.SharePoint.Client.ChangeToken CurrentChangeToken { get; } + + Microsoft.SharePoint.Client.User CurrentUser { get; } + + string CustomMasterUrl { get; set; } + + bool CustomSiteActionsDisabled { get; set; } + + Microsoft.SharePoint.Client.SPDataLeakagePreventionStatusInfo DataLeakagePreventionStatusInfo { get; } + + string Description { get; set; } + + Microsoft.SharePoint.Client.UserResource DescriptionResource { get; } + + System.Collections.Generic.IEnumerable DescriptionTranslations { get; set; } + + string DesignerDownloadUrlForCurrentUser { get; } + + System.Guid DesignPackageId { get; set; } + + bool DisableAppViews { get; set; } + + bool DisableFlows { get; set; } + + bool DisableRecommendedItems { get; set; } + + bool DocumentLibraryCalloutOfficeWebAppPreviewersDisabled { get; } + + Microsoft.SharePoint.Client.BasePermissions EffectiveBasePermissions { get; } + + bool EnableMinimalDownload { get; set; } + + Microsoft.SharePoint.Client.EventReceiverDefinitionCollection EventReceivers { get; } + + bool ExcludeFromOfflineClient { get; set; } + + Microsoft.SharePoint.Client.FeatureCollection Features { get; } + + Microsoft.SharePoint.Client.FieldCollection Fields { get; } + + Microsoft.SharePoint.Client.FolderCollection Folders { get; } + + Microsoft.SharePoint.Client.FooterVariantThemeType FooterEmphasis { get; set; } + + bool FooterEnabled { get; set; } + + Microsoft.SharePoint.Client.FooterLayoutType FooterLayout { get; set; } + + bool HasWebTemplateExtension { get; set; } + + Microsoft.SharePoint.Client.SPVariantThemeType HeaderEmphasis { get; set; } + + Microsoft.SharePoint.Client.HeaderLayoutType HeaderLayout { get; set; } + + bool HideTitleInHeader { get; set; } + + bool HorizontalQuickLaunch { get; set; } + + Microsoft.SharePoint.ClientSideComponent.HostedAppsManager HostedApps { get; } + + System.Guid Id { get; } + + bool IsHomepageModernized { get; } + + bool IsMultilingual { get; set; } + + bool IsProvisioningComplete { get; } + + bool IsRevertHomepageLinkHidden { get; set; } + + uint Language { get; } + + System.DateTime LastItemModifiedDate { get; } + + System.DateTime LastItemUserModifiedDate { get; } + + Microsoft.SharePoint.Client.ListCollection Lists { get; } + + Microsoft.SharePoint.Client.ListTemplateCollection ListTemplates { get; } + + Microsoft.SharePoint.Client.LogoAlignment LogoAlignment { get; set; } + + string MasterUrl { get; set; } + + bool MegaMenuEnabled { get; set; } + + bool MembersCanShare { get; set; } + + bool NavAudienceTargetingEnabled { get; set; } + + Microsoft.SharePoint.Client.Navigation Navigation { get; } + + bool NextStepsFirstRunEnabled { get; set; } + + bool NoCrawl { get; set; } + + bool NotificationsInOneDriveForBusinessEnabled { get; } + + bool NotificationsInSharePointEnabled { get; } + + bool ObjectCacheEnabled { get; set; } + + bool OverwriteTranslationsOnChange { get; set; } + + Microsoft.SharePoint.Client.WebInformation ParentWeb { get; } + + Microsoft.SharePoint.Client.ResourcePath ResourcePath { get; } + + bool PreviewFeaturesEnabled { get; } + + string PrimaryColor { get; } + + Microsoft.SharePoint.Client.PushNotificationSubscriberCollection PushNotificationSubscribers { get; } + + bool QuickLaunchEnabled { get; set; } + + Microsoft.SharePoint.Client.RecycleBinItemCollection RecycleBin { get; } + + bool RecycleBinEnabled { get; } + + Microsoft.SharePoint.Client.RegionalSettings RegionalSettings { get; } + + string RequestAccessEmail { get; set; } + + Microsoft.SharePoint.Client.RoleDefinitionCollection RoleDefinitions { get; } + + Microsoft.SharePoint.Client.Folder RootFolder { get; } + + bool SaveSiteAsTemplateEnabled { get; set; } + + Microsoft.SharePoint.Client.SearchBoxInNavBarType SearchBoxInNavBar { get; set; } + + string SearchBoxPlaceholderText { get; set; } + + Microsoft.SharePoint.Client.SearchScopeType SearchScope { get; set; } + + Microsoft.SharePoint.Client.ResourcePath ServerRelativePath { get; } + + string ServerRelativeUrl { get; set; } + + bool ShowUrlStructureForCurrentUser { get; } + + Microsoft.SharePoint.Marketplace.CorporateCuratedGallery.SiteCollectionCorporateCatalogAccessor SiteCollectionAppCatalog { get; } + + Microsoft.SharePoint.Client.GroupCollection SiteGroups { get; } + + string SiteLogoDescription { get; set; } + + string SiteLogoUrl { get; set; } + + Microsoft.SharePoint.Client.List SiteUserInfoList { get; } + + Microsoft.SharePoint.Client.UserCollection SiteUsers { get; } + + System.Collections.Generic.IEnumerable SupportedUILanguageIds { get; set; } + + bool SyndicationEnabled { get; set; } + + Microsoft.SharePoint.Client.SharingState TenantAdminMembersCanShare { get; } + + Microsoft.SharePoint.Marketplace.CorporateCuratedGallery.TenantCorporateCatalogAccessor TenantAppCatalog { get; } + + bool TenantTagPolicyEnabled { get; } + + string ThemedCssFolderUrl { get; set; } + + Microsoft.SharePoint.Client.ThemeInfo ThemeInfo { get; } + + bool ThirdPartyMdmEnabled { get; } + + string Title { get; set; } + + Microsoft.SharePoint.Client.UserResource TitleResource { get; } + + System.Collections.Generic.IEnumerable TitleTranslations { get; set; } + + bool TreeViewEnabled { get; set; } + + int UIVersion { get; set; } + + bool UIVersionConfigurationEnabled { get; set; } + + string Url { get; } + + bool UseAccessRequestDefault { get; } + + Microsoft.SharePoint.Client.UserCustomActionCollection UserCustomActions { get; } + + Microsoft.SharePoint.Client.WebCollection Webs { get; } + + string WebTemplate { get; } + + string WebTemplateConfiguration { get; } + + bool WebTemplatesGalleryFirstRunEnabled { get; set; } + + string WelcomePage { get; } + + Microsoft.SharePoint.Client.Workflow.WorkflowAssociationCollection WorkflowAssociations { get; } + + Microsoft.SharePoint.Client.Workflow.WorkflowTemplateCollection WorkflowTemplates { get; } + + + + System.Uri WebUrlFromPageUrlDirect(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext context, System.Uri pageFullUrl); + + System.Uri WebUrlFromFolderUrlDirect(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext context, System.Uri folderFullUrl); + + Microsoft.SharePoint.Client.ClientResult DoesUserHavePermissions(Microsoft.SharePoint.Client.BasePermissions permissionMask); + + Microsoft.SharePoint.Client.ClientResult GetUserEffectivePermissions(string userName); + + void CreateDefaultAssociatedGroups(string userLogin, string userLogin2, string groupNameSeed); + + Microsoft.SharePoint.Client.User GetUserById(int userId); + + Microsoft.SharePoint.Client.ClientResult EnsureTenantAppCatalog(string callerId); + + Microsoft.SharePoint.ClientSideComponent.StorageEntity GetStorageEntity(string key); + + void SetStorageEntity(string key, string value, string description, string comments); + + void RemoveStorageEntity(string key); + + Microsoft.SharePoint.Client.SharingResult ShareObject(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, string peoplePickerInput, string roleValue, int groupId, bool propagateAcl, bool sendEmail, bool includeAnonymousLinkInEmail, string emailSubject, string emailBody, bool useSimplifiedRoles); + + Microsoft.SharePoint.Client.SharingResult ForwardObjectLink(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, string peoplePickerInput, string emailSubject, string emailBody); + + Microsoft.SharePoint.Client.SharingResult UnshareObject(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url); + + Microsoft.SharePoint.Client.ObjectSharingSettings GetObjectSharingSettings(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string objectUrl, int groupId, bool useSimplifiedRoles); + + Microsoft.SharePoint.Client.ClientResult CreateAnonymousLink(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink); + + Microsoft.SharePoint.Client.ClientResult CreateAnonymousLinkWithExpiration(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink, string expirationString); + + void DeleteAllAnonymousLinksForObject(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url); + + void DeleteAnonymousLinkForObject(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink, bool removeAssociatedSharingLinkGroup); + + Microsoft.SharePoint.Client.ClientResult CreateOrganizationSharingLink(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink); + + void DestroyOrganizationSharingLink(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string url, bool isEditLink, bool removeAssociatedSharingLinkGroup); + + Microsoft.SharePoint.Client.ClientResult GetSharingLinkKind(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string fileUrl); + + Microsoft.SharePoint.Client.ClientResult GetSharingLinkData(string linkUrl); + + Microsoft.SharePoint.Client.ClientResult MapToIcon(string fileName, string progId, Microsoft.SharePoint.Client.Utilities.IconSize size); + + Microsoft.SharePoint.Client.ClientResult GetWebUrlFromPageUrl(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string pageFullUrl); + + Microsoft.SharePoint.Client.PushNotificationSubscriber RegisterPushNotificationSubscriber(System.Guid deviceAppInstanceId, string serviceToken); + + void UnregisterPushNotificationSubscriber(System.Guid deviceAppInstanceId); + + Microsoft.SharePoint.Client.PushNotificationSubscriberCollection GetPushNotificationSubscribersByArgs(string customArgs); + + Microsoft.SharePoint.Client.PushNotificationSubscriberCollection GetPushNotificationSubscribersByUser(string userName); + + Microsoft.SharePoint.Client.ClientResult DoesPushNotificationSubscriberExist(System.Guid deviceAppInstanceId); + + Microsoft.SharePoint.Client.PushNotificationSubscriber GetPushNotificationSubscriber(System.Guid deviceAppInstanceId); + + Microsoft.SharePoint.Client.RecycleBinItemCollection GetRecycleBinItems(string pagingInfo, int rowLimit, bool isAscending, Microsoft.SharePoint.Client.RecycleBinOrderBy orderBy, Microsoft.SharePoint.Client.RecycleBinItemState itemState); + + Microsoft.SharePoint.Client.RecycleBinItemCollection GetRecycleBinItemsByQueryInfo(Microsoft.SharePoint.Client.RecycleBinQueryInformation queryInfo); + + Microsoft.SharePoint.Client.ChangeCollection GetChanges(Microsoft.SharePoint.Client.ChangeQuery query); + + Microsoft.SharePoint.Client.List GetList(string strUrl); + + Microsoft.SharePoint.Client.List GetListUsingPath(Microsoft.SharePoint.Client.ResourcePath path); + + Microsoft.SharePoint.Client.ListItem GetListItem(string strUrl); + + Microsoft.SharePoint.Client.ListItem GetListItemUsingPath(Microsoft.SharePoint.Client.ResourcePath path); + + Microsoft.SharePoint.Client.ListItem GetListItemByResourceId(string resourceId); + + Microsoft.BusinessData.MetadataModel.Entity GetEntity(string @namespace, string name); + + Microsoft.BusinessData.MetadataModel.AppBdcCatalog GetAppBdcCatalogForAppInstance(System.Guid appInstanceId); + + Microsoft.BusinessData.MetadataModel.AppBdcCatalog GetAppBdcCatalog(); + + Microsoft.SharePoint.Client.WebCollection GetSubwebsForCurrentUser(Microsoft.SharePoint.Client.SubwebQuery query); + + Microsoft.SharePoint.Client.ClientResult GetSPAppContextAsStream(); + + Microsoft.SharePoint.Client.WebTemplateCollection GetAvailableWebTemplates(uint lcid, bool doIncludeCrossLanguage); + + Microsoft.SharePoint.Client.List GetCatalog(int typeCatalog); + + Microsoft.SharePoint.Client.View GetViewFromUrl(string listUrl); + + Microsoft.SharePoint.Client.View GetViewFromPath(Microsoft.SharePoint.Client.ResourcePath listPath); + + Microsoft.SharePoint.Client.File GetFileByServerRelativeUrl(string serverRelativeUrl); + + Microsoft.SharePoint.Client.File GetFileByServerRelativePath(Microsoft.SharePoint.Client.ResourcePath serverRelativePath); + + System.Collections.Generic.IList GetDocumentLibraries(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string webFullUrl); + + System.Collections.Generic.IList GetDocumentAndMediaLibraries(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string webFullUrl, bool includePageLibraries); + + Microsoft.SharePoint.Client.ClientResult DefaultDocumentLibraryUrl(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext context, string webUrl); + + Microsoft.SharePoint.Client.List DefaultDocumentLibrary(); + + Microsoft.SharePoint.Client.File GetFileById(System.Guid uniqueId); + + Microsoft.SharePoint.Client.Folder GetFolderById(System.Guid uniqueId); + + Microsoft.SharePoint.Client.File GetFileByLinkingUrl(string linkingUrl); + + Microsoft.SharePoint.Client.File GetFileByGuestUrl(string guestUrl); + + Microsoft.SharePoint.Client.File GetFileByGuestUrlEnsureAccess(string guestUrl, bool ensureAccess); + + Microsoft.SharePoint.Client.File GetFileByWOPIFrameUrl(string wopiFrameUrl); + + Microsoft.SharePoint.Client.File GetFileByUrl(string fileUrl); + + Microsoft.SharePoint.Client.Folder GetFolderByServerRelativeUrl(string serverRelativeUrl); + + Microsoft.SharePoint.Client.Folder GetFolderByServerRelativePath(Microsoft.SharePoint.Client.ResourcePath serverRelativePath); + + void ApplyWebTemplate(string webTemplate); + + void DeleteObject(); + + void Update(); + + Microsoft.SharePoint.Client.ClientResult PageContextInfo(bool includeODBSettings, bool emitNavigationInfo); + + Microsoft.SharePoint.Client.ClientResult PageContextCore(); + + Microsoft.SharePoint.Client.AppInstance GetAppInstanceById(System.Guid appInstanceId); + + Microsoft.SharePoint.Client.ClientObjectList GetAppInstancesByProductId(System.Guid productId); + + Microsoft.SharePoint.Client.AppInstance LoadAndInstallAppInSpecifiedLocale(System.IO.Stream appPackageStream, int installationLocaleLCID); + + Microsoft.SharePoint.Client.AppInstance LoadApp(System.IO.Stream appPackageStream, int installationLocaleLCID); + + Microsoft.SharePoint.Client.ClientResult AddPlaceholderUser(string listId, string placeholderText); + + Microsoft.SharePoint.Client.AppInstance LoadAndInstallApp(System.IO.Stream appPackageStream); + + void SetAccessRequestSiteDescriptionAndUpdate(string description); + + void SetUseAccessRequestDefaultAndUpdate(bool useAccessRequestDefault); + + void IncrementSiteClientTag(); + + void AddSupportedUILanguage(int lcid); + + void RemoveSupportedUILanguage(int lcid); + + Microsoft.SharePoint.Client.User EnsureUser(string logonName); + + Microsoft.SharePoint.Client.User EnsureUserByObjectId(System.Guid objectId, System.Guid tenantId, Microsoft.SharePoint.Client.Utilities.PrincipalType principalType); + + void ApplyTheme(string colorPaletteUrl, string fontSchemeUrl, string backgroundImageUrl, bool shareGenerated); + + + + + } +} +#nullable disable \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/PnPTests.cs b/tests/ProxyInterfaceSourceGeneratorTests/PnPTests.cs new file mode 100644 index 0000000..f9a8dc6 --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/PnPTests.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CSharp.SourceGenerators.Extensions.Models; +using Moq; +using ProxyInterfaceSourceGenerator; +using ProxyInterfaceSourceGeneratorTests.Source; +using ProxyInterfaceSourceGeneratorTests.Source.PnP; +using Xunit; + +namespace ProxyInterfaceSourceGeneratorTests +{ + public class PnPTests + { + public PnPTests() + { + + } + + [Fact] + public void X() + { + var webMock = new Mock(); + + + var ccMock = new Mock(); + // ccMock.SetupGet(cc => cc.Web).Returns(webMock.Object); + + } + } +} diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs index 75a7d78..a4dbdc6 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs +++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTest.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Linq; using CSharp.SourceGenerators.Extensions; using CSharp.SourceGenerators.Extensions.Models; using FluentAssertions; @@ -65,7 +66,7 @@ namespace ProxyInterfaceSourceGeneratorTests AttributeToAddToInterface = new ExtraAttribute { Name = "ProxyInterfaceGenerator.Proxy", - ArgumentList = new [] { "typeof(ProxyInterfaceSourceGeneratorTests.Source.PersonExtends)", "true" } + ArgumentList = new[] { "typeof(ProxyInterfaceSourceGeneratorTests.Source.PersonExtends)", "true" } } }; @@ -138,8 +139,6 @@ namespace ProxyInterfaceSourceGeneratorTests result.Valid.Should().BeTrue(); result.Files.Should().HaveCount(5); - // throw new Exception(); - // Assert attribute var attribute = result.Files[0].SyntaxTree; attribute.FilePath.Should().EndWith(attributeFilename); @@ -180,5 +179,93 @@ namespace ProxyInterfaceSourceGeneratorTests if (Write) File.WriteAllText($"../../../Destination/{proxyClassPersonFilename}", proxyCode); proxyCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassPersonFilename}")); } + + [Fact] + public void GenerateFiles_ForPnP_Should_GenerateCorrectFiles() + { + // Arrange + var fileNames = new[] + { + "ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs", + "ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs", + "ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs", + "ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs", + + "Microsoft.SharePoint.Client.ClientObjectProxy.g.cs", + "Microsoft.SharePoint.Client.WebProxy.g.cs", + "Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs", + "Microsoft.SharePoint.Client.ClientContextProxy.g.cs" + }; + + var pathClientObject = "./Source/PnP/IClientObject.cs"; + var sourceFileClientObject = new SourceFile + { + Path = pathClientObject, + Text = File.ReadAllText(pathClientObject), + AttributeToAddToInterface = new ExtraAttribute + { + Name = "ProxyInterfaceGenerator.Proxy", + ArgumentList = "typeof(Microsoft.SharePoint.Client.ClientObject)" + } + }; + + var pathWeb = "./Source/PnP/IWeb.cs"; + var sourceFileWeb = new SourceFile + { + Path = pathWeb, + Text = File.ReadAllText(pathWeb), + AttributeToAddToInterface = new ExtraAttribute + { + Name = "ProxyInterfaceGenerator.Proxy", + ArgumentList = "typeof(Web)" // Only name, no namespace + } + }; + + var pathClientRuntimeContext = "./Source/Pnp/IClientRuntimeContext.cs"; + var sourceFileClientRuntimeContext = new SourceFile + { + Path = pathClientRuntimeContext, + Text = File.ReadAllText(pathClientRuntimeContext), + AttributeToAddToInterface = new ExtraAttribute + { + Name = "ProxyInterfaceGenerator.Proxy", + ArgumentList = "typeof(Microsoft.SharePoint.Client.ClientRuntimeContext)" + } + }; + + var pathClientContext = "./Source/PnP/IClientContext.cs"; + var sourceFileClientContext = new SourceFile + { + Path = pathClientContext, + Text = File.ReadAllText(pathClientContext), + AttributeToAddToInterface = new ExtraAttribute + { + Name = "ProxyInterfaceGenerator.Proxy", + ArgumentList = "typeof(ClientContext)" // Only name, no namespace + } + }; + + // Act + var result = _sut.Execute(new[] + { + sourceFileClientObject, + sourceFileWeb, + sourceFileClientRuntimeContext, + sourceFileClientContext + }); + + // Assert + result.Valid.Should().BeTrue(); + result.Files.Should().HaveCount(fileNames.Length + 1); + + foreach (var fileName in fileNames.Select((fileName, index) => new { fileName, index })) + { + var builder = result.Files[fileName.index + 1]; // +1 means skip the attribute + builder.Path.Should().EndWith(fileName.fileName); + + if (Write) File.WriteAllText($"../../../Destination/{fileName.fileName}", builder.Text); + builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}")); + } + } } } \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj index fdf3227..8f54307 100644 --- a/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj +++ b/tests/ProxyInterfaceSourceGeneratorTests/ProxyInterfaceSourceGeneratorTests.csproj @@ -12,6 +12,8 @@ + + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -32,9 +34,12 @@ - - PreserveNewest - + + PreserveNewest + + + PreserveNewest + \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientContext.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientContext.cs new file mode 100644 index 0000000..5065424 --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientContext.cs @@ -0,0 +1,9 @@ +using Microsoft.SharePoint.Client; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial interface IClientContext + { + + } +} \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientObject.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientObject.cs new file mode 100644 index 0000000..727653c --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientObject.cs @@ -0,0 +1,6 @@ +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial interface IClientObject + { + } +} diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientRuntimeContext.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientRuntimeContext.cs new file mode 100644 index 0000000..a3d813e --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IClientRuntimeContext.cs @@ -0,0 +1,27 @@ +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial interface IClientRuntimeContext + { + } +} + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial class ClientRuntimeContextProxy + { + public T CastTo2(ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject obj) + where T : ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject + //where TOriginal : Microsoft.SharePoint.Client.ClientObject + { + Microsoft.SharePoint.Client.ClientObject obj_ = _mapper.Map(obj); + var result_366781530 = _Instance.CastTo(obj_); + return _mapper.Map(result_366781530); + } + + public void X() + { + var x = CastTo2(new ClientObjectProxy(default)); + } + + } +} \ No newline at end of file diff --git a/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IWeb.cs b/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IWeb.cs new file mode 100644 index 0000000..d95ab0c --- /dev/null +++ b/tests/ProxyInterfaceSourceGeneratorTests/Source/PnP/IWeb.cs @@ -0,0 +1,8 @@ +using Microsoft.SharePoint.Client; + +namespace ProxyInterfaceSourceGeneratorTests.Source.PnP +{ + public partial interface IWeb + { + } +} \ No newline at end of file