System.Reflection.Assembly.GetAssembly(System.Type)

Here are the examples of the csharp api System.Reflection.Assembly.GetAssembly(System.Type) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

823 Examples 7

19 Source : ManifestParameterizator.cs
with MIT License
from aslotte

private string ReadResource(string fileName)
        {
            var replacedembly = replacedembly.Getreplacedembly(typeof(ManifestParameterizator));
            var resourceName = string.Join(".", replacedembly.GetName().Name, "Kubernetes.Manifests", fileName);

            using Stream stream = replacedembly.GetManifestResourceStream(resourceName);
            using StreamReader reader = new StreamReader(stream);
            return reader.ReadToEnd();
        }

19 Source : MLOpsDbContext.cs
with MIT License
from aslotte

protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            this.onModelCreating(modelBuilder);

            modelBuilder.ApplyConfigurationsFromreplacedembly(replacedembly.Getreplacedembly(typeof(MLOpsDbContext)));

            base.OnModelCreating(modelBuilder);
        }

19 Source : AttributeTests.cs
with Apache License 2.0
from atata-framework

[Test]
        public void replacedembly()
        {
            AtataContextBuilder builder = AtataContext.Configure().
                ApplyJsonConfig("Configs/Attributes/replacedembly");

            var result = builder.BuildingContext.Attributes.replacedemblyMap;

            result.Should().HaveCount(2);

            var replacedembly1 = System.Reflection.replacedembly.Getreplacedembly(GetType());

            result[replacedembly1].Should().ContainSingle()
                .Which.Should().BeOfType<FindByIdAttribute>()
                .Which.Values.Should().Equal("some-id");

            var replacedembly2 = System.Reflection.replacedembly.Getreplacedembly(typeof(AtataContext));

            result[replacedembly2].Should().ContainSingle()
                .Which.Should().BeOfType<FindByNameAttribute>()
                .Which.Values.Should().Equal("some-name");
        }

19 Source : AdditionaHelpingGuidance.cs
with MIT License
from Avatarchik

private static void PlaymodeStateChanged()
        {
            // If we've just changed our mode to a playmode
            if (EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode)
            {
                var types = from t in replacedembly.Getreplacedembly(typeof(SimpleButton)).GetTypes()
                            where 
                                t.IsClreplaced 
                                && t.Namespace == "CnControls"
                                && t.IsSubclreplacedOf(typeof(MonoBehaviour))
                            select t;

                // If there are any CnControls on the scene
                bool shouldCheckForErrors = types.Any(type => Object.FindObjectOfType(type));

                if (shouldCheckForErrors)
                {
                    CheckForEventSystemPresence();
                }
            }
        }

19 Source : MockWebResponse.cs
with Apache License 2.0
from aws

public static HttpResponseMessage Create(HttpStatusCode statusCode, IDictionary<string, string> headers, string body = null)
        {
            var type = typeof(HttpResponseMessage);
            var replacedembly = replacedembly.Getreplacedembly(type);
            var obj = replacedembly.CreateInstance("System.Net.Http.HttpResponseMessage");

            HttpResponseMessage httpResponseMessage = obj as HttpResponseMessage;
            var webHeaders = new WebHeaderCollection();
            if (headers != null)
            {
                foreach (var header in headers)
                {
                    webHeaders.Add(header.Key, header.Value);
                    httpResponseMessage.Headers.Add(header.Key, header.Value);
                }
            }

            Stream responseBodyStream = null;
            body = body ?? string.Empty;
            responseBodyStream = Utils.CreateStreamFromString(body);
            httpResponseMessage.StatusCode = statusCode;
            StreamReader streamReader = new StreamReader($"JSONs{Path.DirectorySeparatorChar}FakeResponse.json");
            string json = streamReader.ReadToEnd();
            httpResponseMessage.Content = new StringContent(json); // Content should be in Json format else we get exception from downstream unmarshalling
            return httpResponseMessage;
        }

19 Source : AWSXRayRecorderTests.cs
with Apache License 2.0
from aws

[TestMethod]
        public void TestXrayContext()
        {
            _recorder.BeginSegment("test", TraceId);
            var segment = AWSXRayRecorder.Instance.TraceContext.GetEnreplacedy();
            _recorder.EndSegment();

            IDictionary<string, string> xray = (ConcurrentDictionary<string, string>)segment.Aws["xray"];
            var versionText =
                FileVersionInfo.GetVersionInfo(replacedembly.Getreplacedembly(typeof(AWSXRayRecorderBuilder)).Location)
                    .ProductVersion;

            replacedert.AreEqual(versionText, xray["sdk_version"]);
#if NET45
            replacedert.AreEqual("X-Ray for .NET", xray["sdk"]);
#else
            replacedert.AreEqual("X-Ray for .NET Core", xray["sdk"]);
#endif
        }

19 Source : TestUtils.cs
with Apache License 2.0
from aws

public static string GetTestreplacedemblySourceDirectory(Type type)
        {
            var tstPath = GetTstPathFromType(type);
            var replacedembly = replacedembly.Getreplacedembly(type);
            var replacedemblyProjectName = replacedembly.GetName().Name;

            return Path.Combine(tstPath, replacedemblyProjectName);
        }

19 Source : ConditionFactory.cs
with Apache License 2.0
from aws

public static Condition GetCondition(ConditionMetadata conditionMetadata)
        {
            var replacedembly = replacedembly.Getreplacedembly(typeof(Condition));
            var clreplacedName = ConditionTypeEnumToClreplacedName(conditionMetadata.Type);
            var conditionType = replacedembly.GetTypes().SingleOrDefault(t => t.Name == clreplacedName);
            if (conditionType == null)
            {
                throw new ClreplacedNotFoundException(replacedembly, clreplacedName);
            }

            if (!(Activator.CreateInstance(conditionType, conditionMetadata) is Condition conditionInstance))
            {
                throw new InvalidCastException($"Type {clreplacedName} cannot be cast to {typeof(Condition)}");
            }

            return conditionInstance;
        }

19 Source : CompiledFeatureFactoryTests.cs
with Apache License 2.0
from aws

[Test]
        public void GetInstance_Returns_Feature_From_replacedembly()
        {
            var featureType = typeof(AspNetMvcFeature);
            var replacedembly = replacedembly.Getreplacedembly(featureType);
            var featureScope = FeatureScope.Project;
            var @namespace = featureType.Namespace;

            var featureName = "FeatureName";
            var clreplacedName = nameof(AspNetMvcFeature);
            var metadata = new CompiledFeatureMetadata
            {
                Name = featureName,
                ClreplacedName = clreplacedName
            };

            var feature = CompiledFeatureFactory.GetInstance(featureScope, replacedembly, @namespace, metadata);

            replacedert.NotNull(feature);
            replacedert.True(feature.Name == featureName);
            replacedert.True(feature.FeatureScope == featureScope);
            replacedert.True(feature is AspNetMvcFeature);
        }

19 Source : CompiledFeatureFactoryTests.cs
with Apache License 2.0
from aws

[Test]
        public void GetInstance_Throws_InvalidFeatureException_If_Type_Is_Not_A_Feature3()
        {
            var notAFeatureType = typeof(StringBuilder);
            var featureMetadata = new CompiledFeatureMetadata
            {
                Name = "SomeName",
                ClreplacedName = notAFeatureType.Name
            };
            var featureScope = FeatureScope.Undefined;
            var replacedembly = replacedembly.Getreplacedembly(notAFeatureType);
            var @namespace = notAFeatureType.Namespace;
            replacedert.Throws<InvalidFeatureException>(() => CompiledFeatureFactory.GetInstance(featureScope, replacedembly, @namespace, featureMetadata));
        }

19 Source : FeatureLoaderTests.cs
with Apache License 2.0
from aws

[Test]
        public void LoadFeaturesFromNamespace_Loads_All_Features_In_Namespace()
        {
            var namespaceSuffix = nameof(global::CTA.FeatureDetection.ProjectType.CompiledFeatures);
            var replacedembly = replacedembly.Getreplacedembly(typeof(AspNetMvcFeature));
            var loadedFeatures = FeatureLoader.LoadFeaturesFromNamespace(replacedembly, namespaceSuffix);
            var loadedFeatureNames = loadedFeatures.Select(f => f.Name);

            var expectedFeatureNames = new[]
            {
                nameof(AspNetMvcFeature),
                nameof(AspNetWebApiFeature),
                nameof(AspNetCoreMvcFeature),
                nameof(AspNetCoreWebApiFeature),
                nameof(WebClreplacedLibraryFeature),
                nameof(CoreWCFServiceCodeFeature),
                nameof(CoreWCFServiceConfigFeature),
                nameof(WCFClientFeature),
                nameof(WCFServiceHostFeature),
                nameof(AspNetWebFormsFeature)
            };

            Collectionreplacedert.AreEquivalent(expectedFeatureNames, loadedFeatureNames);
        }

19 Source : FeatureLoaderTests.cs
with Apache License 2.0
from aws

[Test]
        public void LoadFeaturesFromNamespace_Returns_An_Empty_Collection_When_Parameters_Are_Invalid2()
        {
            var validreplacedembly = replacedembly.Getreplacedembly(typeof(AspNetMvcFeature));
            var invalidNamespaceSuffix = string.Empty;
            var loadedFeatures = FeatureLoader.LoadFeaturesFromNamespace(validreplacedembly, invalidNamespaceSuffix);

            Collectionreplacedert.IsEmpty(loadedFeatures);
        }

19 Source : CmdletFinder.cs
with MIT License
from azist

public static IEnumerable<Type> Find(Type replacedemblyContainingType, Func<Type, bool> filter = null)
    {
      if (replacedemblyContainingType==null) replacedemblyContainingType = typeof(CmdletFinder);
      var asm = replacedembly.Getreplacedembly(replacedemblyContainingType);
      var cmdlets = asm.GetTypes()
                       .Where(t => !t.IsAbstract && typeof(Cmdlet).IsreplacedignableFrom(t));

      return filter!=null? cmdlets.Where( t => filter(t)) : cmdlets;
    }

19 Source : BatchSchemaProvider.cs
with MIT License
from Azure

private static string GetEmbeddedResource(string resourceName)
        {
            replacedembly replacedembly = replacedembly.Getreplacedembly(typeof(BatchSchemaProvider));

            // replacedumes BatchSchemaProvider is in the default namespace of the replacedembly.
            resourceName = BatchSchemaProvider.FormatResourceName(typeof(BatchSchemaProvider).Namespace, resourceName);

            using (Stream resourceStream = replacedembly.GetManifestResourceStream(resourceName))
            {
                if (resourceStream == null)
                {
                    return null;
                }

                using (StreamReader reader = new StreamReader(resourceStream))
                {
                    return reader.ReadToEnd();
                }
            }
        }

19 Source : CosmosVirtualUnitTest.cs
with MIT License
from Azure

[TestMethod]
        [Ignore]
        public void VerifyAllPublicMembersAreVirtualUnitTesting()
        {
            // All of the public properties and methods should be virtual to allow users to 
            // create unit tests by mocking the different types. Data Contracts do not support mocking so exclude all types that end with Settings.
            IEnumerable<Type> allClreplacedes = from t in replacedembly.Getreplacedembly(typeof(CosmosClient)).GetTypes()
                                           where t.IsClreplaced && t.Namespace == "Microsoft.Azure.Cosmos" && t.IsPublic && !t.IsAbstract && !t.IsSealed
                                           where !t.Name.EndsWith("Properties")
                                           select t;

            // Get the entire list to prevent running the test for each method/property
            List<Tuple<string, string>> nonVirtualPublic = new List<Tuple<string, string>>();
            foreach (Type publiClreplaced in allClreplacedes)
            {
                // DeclaredOnly flag gets only the properties declared in the current clreplaced. 
                // This ignores inherited properties to prevent duplicate findings.
                IEnumerable<Tuple<string, string>> allProps = publiClreplaced.GetProperties(BindingFlags.DeclaredOnly)
                    .Where(x => !x.GetGetMethod().IsVirtual && x.GetGetMethod().IsPublic && !x.CanWrite)
                    .Select(x => new Tuple<string, string>(publiClreplaced.FullName, x.Name));
                nonVirtualPublic.AddRange(allProps);

                IEnumerable<Tuple<string, string>> allMethods = publiClreplaced.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
                    .Where(x => !x.IsVirtual && x.IsPublic && !x.IsSpecialName)
                    .Where(x => x.GetCustomAttribute<IgnoreForUnitTest>(false) == null)
                    .Select(x => new Tuple<string, string>(publiClreplaced.FullName, x.Name));
                nonVirtualPublic.AddRange(allMethods);
            }

            replacedert.AreEqual(0, nonVirtualPublic.Count,
                "The following methods and properties should be virtual to allow unit testing:" +
                string.Join(";", nonVirtualPublic.Select(x => $"Clreplaced:{x.Item1}; Member:{x.Item2}")));
        }

19 Source : CosmosVirtualUnitTest.cs
with MIT License
from Azure

[TestMethod]
        public void VerifyAllPublicClreplacedesCanBeMocked()
        {
            // The following clreplacedes are public, but not meant to be mocked.
            HashSet<string> nonMockableClreplacedes = new HashSet<string>()
            {
                "ChangeFeedStartFrom",
                "ChangeFeedMode"
            };

            // All of the public clreplacedes should not contain an internal abstract method
            // create unit tests by mocking the different types. Data Contracts do not support mocking so exclude all types that end with Settings.
            IEnumerable<Type> allClreplacedes = from t in replacedembly.Getreplacedembly(typeof(CosmosClient)).GetTypes()
                                           where
                                                t.IsClreplaced &&
                                                t.Namespace == "Microsoft.Azure.Cosmos" &&
                                                t.IsPublic &&
                                                !nonMockableClreplacedes.Contains(t.Name)
                                           select t;

            // Get the entire list to prevent running the test for each method/property
            List<Tuple<string, string>> nonVirtualPublic = new List<Tuple<string, string>>();
            foreach (Type publicClreplaced in allClreplacedes)
            {
                // DeclaredOnly flag gets only the properties declared in the current clreplaced. 
                // This ignores inherited properties to prevent duplicate findings.
                IEnumerable<Tuple<string, string>> allProps = publicClreplaced.GetProperties(BindingFlags.DeclaredOnly)
                    .Where(x => x.GetGetMethod().IsAbstract && !x.GetGetMethod().IsPublic)
                    .Select(x => new Tuple<string, string>(publicClreplaced.FullName, x.Name));
                nonVirtualPublic.AddRange(allProps);

                IEnumerable<Tuple<string, string>> allMethods = publicClreplaced.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)
                    .Where(x => x.IsAbstract && !x.IsPublic)
                    .Select(x => new Tuple<string, string>(publicClreplaced.FullName, x.Name));
                nonVirtualPublic.AddRange(allMethods);
            }

            replacedert.AreEqual(0, nonVirtualPublic.Count,
                "The following methods and properties should be virtual to allow mocking:" +
                string.Join(";", nonVirtualPublic.Select(x => $"Clreplaced:{x.Item1}; Member:{x.Item2}")));
        }

19 Source : CosmosVirtualUnitTest.cs
with MIT License
from Azure

[TestMethod]
        public void VerifyInlineOverride()
        {
            replacedembly replacedembly = replacedembly.Getreplacedembly(typeof(CosmosClient));
            IEnumerable<Type> allClreplacedes = from t in replacedembly.GetTypes()
                                           where t.IsClreplaced && !t.IsPublic && !t.IsAbstract
                                           where t.Namespace != null
                                           where t.Namespace.StartsWith("Microsoft.Azure.Cosmos") && t.Name.EndsWith("InlineCore")
                                           select t;

            List<Type> inlineClreplacedes = allClreplacedes.ToList();
            replacedert.IsTrue(inlineClreplacedes.Count >= 7);

            foreach (Type inlineType in inlineClreplacedes)
            {
                string contractClreplacedName = inlineType.FullName.Replace("InlineCore", string.Empty);
                Type contractClreplaced = replacedembly.GetType(contractClreplacedName);
                replacedert.IsNotNull(contractClreplaced);
                string[] allContractMethods = contractClreplaced.GetMethods()
                    .Where(x => x.DeclaringType == contractClreplaced && x.Name.EndsWith("Async"))
                    .Select(x => x.ToString())
                    .ToArray();

                HashSet<string> allInlineMethods = inlineType.GetMethods()
                    .Where(x => x.Name.EndsWith("Async") && x.DeclaringType == inlineType)
                    .Select(x => x.ToString())
                    .ToHashSet<string>();

                foreach (string contractMethod in allContractMethods)
                {
                    if (!allInlineMethods.Contains(contractMethod))
                    {
                        replacedert.Fail($"The clreplaced: {inlineType.FullName} does not override method \"{contractMethod}\" in the inline clreplaced");
                    }
                }
            }
        }

19 Source : EnvironmentInformationTests.cs
with MIT License
from Azure

[TestMethod]
        public void ClientVersionIsNotNull()
        {
            EnvironmentInformation envInfo = new EnvironmentInformation();
            replacedert.IsNotNull(envInfo.ClientVersion);

            Version sdkVersion = replacedembly.Getreplacedembly(typeof(CosmosClient)).GetName().Version;
            replacedert.AreEqual($"{sdkVersion.Major}.{sdkVersion.Minor}.{sdkVersion.Build}", envInfo.ClientVersion, "Version format differs");
        }

19 Source : OpenApiConfigurationResolverTests.cs
with MIT License
from Azure

[TestMethod]
        public void Given_replacedembly_When_Resolve_Invoked_Then_It_Should_Return_Result()
        {
            var replacedembly = replacedembly.Getreplacedembly(typeof(DefaultOpenApiConfigurationOptions));

            var result = OpenApiConfigurationResolver.Resolve(replacedembly);

            result.Should().BeOfType<DefaultOpenApiConfigurationOptions>();
        }

19 Source : IntegrationTestBase.cs
with MIT License
from Azure

private static string GetPathToBin()
        {
            return Path.GetDirectoryName(replacedembly.Getreplacedembly(typeof(Product)).Location);
        }

19 Source : ServiceCollectionExtensions.cs
with MIT License
from banksystembg

public static IServiceCollection AddDomainServices(this IServiceCollection services)
        {
            var replacedembly = replacedembly.Getreplacedembly(typeof(IService));

            AddreplacedemblyServices(services, replacedembly);

            return services;
        }

19 Source : ServiceCollectionExtensions.cs
with MIT License
from banksystembg

public static IServiceCollection AddCommonProjectServices(this IServiceCollection services)
        {
            var replacedembly = replacedembly.Getreplacedembly(typeof(IEmailSender));
            AddreplacedemblyServices(services, replacedembly);
            services.AddAutoMapper(typeof(DefaultProfile));

            return services;
        }

19 Source : ModDefExLoading.cs
with The Unlicense
from BattletechModders

internal static void Setup()
        {
            // setup replacedembly resolver
            TryResolvereplacedemblies.Add("0Harmony", replacedembly.Getreplacedembly(typeof(HarmonyInstance)));
            AppDomain.CurrentDomain.replacedemblyResolve += (sender, args) =>
            {
                var resolvingName = new replacedemblyName(args.Name);
                return !TryResolvereplacedemblies.TryGetValue(resolvingName.Name, out var replacedembly) ? null : replacedembly;
            };
        }

19 Source : NoAllocHelpers.cs
with MIT License
from bbtarzan12

public static T[] ExtractArrayFromListT<T>(List<T> list)
     {
         if (!ExtractArrayFromListTDelegates.TryGetValue(typeof(T), out var obj))
         {
             var replaced = replacedembly.Getreplacedembly(typeof(Mesh)); // any clreplaced in UnityEngine
             var type = replaced.GetType("UnityEngine.NoAllocHelpers");
             var methodInfo = type.GetMethod("ExtractArrayFromListT", BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(typeof(T));

             obj = ExtractArrayFromListTDelegates[typeof(T)] = Delegate.CreateDelegate(typeof(Func<List<T>, T[]>), methodInfo);
         }

         var func = (Func<List<T>, T[]>) obj;
         return func.Invoke(list);
     }

19 Source : NoAllocHelpers.cs
with MIT License
from bbtarzan12

public static void ResizeList<T>(List<T> list, int size)
     {
         if (!ResizeListDelegates.TryGetValue(typeof(T), out var obj))
         {
             var replaced = replacedembly.Getreplacedembly(typeof(Mesh)); // any clreplaced in UnityEngine
             var type = replaced.GetType("UnityEngine.NoAllocHelpers");
             var methodInfo = type.GetMethod("ResizeList", BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(typeof(T));
             obj = ResizeListDelegates[typeof(T)] = Delegate.CreateDelegate(typeof(Action<List<T>, int>), methodInfo);
         }

         var action = (Action<List<T>, int>) obj;
         action.Invoke(list, size);
     }

19 Source : GatewayDbContext.cs
with Apache License 2.0
from bcgov

private static string ReadResource(string resource)
        {
            replacedembly? replacedembly = replacedembly.Getreplacedembly(typeof(GatewayDbContext));
            Stream? resourceStream = replacedembly!.GetManifestResourceStream(resource);
            using StreamReader reader = new StreamReader(resourceStream!, Encoding.UTF8);
            return reader.ReadToEnd();
        }

19 Source : ServiceCollectionExtensions.cs
with Apache License 2.0
from bcgov

public static IServiceCollection AddMapster(this IServiceCollection services, Action<TypeAdapterConfig> options = null)
        {
            var config = TypeAdapterConfig.GlobalSettings;
            config.Scan(replacedembly.Getreplacedembly(typeof(Startup)));

            options?.Invoke(config);

            services.AddSingleton(config);
            services.AddScoped<IMapper, ServiceMapper>();

            return services;
        }

19 Source : ServiceCollectionExtensions.cs
with Apache License 2.0
from bcgov

public static IServiceCollection AddMapster(this IServiceCollection services, JsonSerializerOptions serializerOptions, Action<TypeAdapterConfig> options = null)
        {
            var config = TypeAdapterConfig.GlobalSettings;

            var optionsSerializer = Microsoft.Extensions.Options.Options.Create(serializerOptions);
            var replacedemblies = new[] { replacedembly.Getreplacedembly(typeof(Startup)) };
            var registers = replacedemblies.Select(replacedembly => replacedembly.GetTypes()
                .Where(x => typeof(IRegister).GetTypeInfo().IsreplacedignableFrom(x.GetTypeInfo()) && x.GetTypeInfo().IsClreplaced && !x.GetTypeInfo().IsAbstract))
                .SelectMany(registerTypes =>
                    registerTypes.Select(registerType =>
                        registerType.GetConstructor(Type.EmptyTypes) == null
                        ? (IRegister)Activator.CreateInstance(registerType, new[] { optionsSerializer })
                        : (IRegister)Activator.CreateInstance(registerType))).ToList();

            config.Apply(registers);

            options?.Invoke(config);

            services.AddSingleton(config);
            services.AddScoped<IMapper, ServiceMapper>();

            return services;
        }

19 Source : ReportService.cs
with Apache License 2.0
from bcgov

private static string ReadTemplate(TemplateType template, ReportFormatType formatType)
        {
            string extension = GetTemplateExtension(formatType);
            string resourceName = $"HealthGateway.WebClient.Server.replacedets.Templates.{template}Report.{extension}";
            replacedembly? replacedembly = replacedembly.Getreplacedembly(typeof(ReportService));
            Stream? resourceStream = replacedembly!.GetManifestResourceStream(resourceName);

            if (resourceStream == null)
            {
                throw new FileNotFoundException($"Template {resourceName} not found.");
            }

            using MemoryStream memoryStream = new MemoryStream();
            resourceStream.CopyTo(memoryStream);
            return Convert.ToBase64String(memoryStream.ToArray());
        }

19 Source : ApplicationBuilderExtensions.cs
with Apache License 2.0
from bcgov

public static IApplicationBuilder UseMapster(this IApplicationBuilder app)
        {
            var config = new TypeAdapterConfig();
            config.Scan(replacedembly.Getreplacedembly(typeof(Startup)));

            return app;
        }

19 Source : Program.cs
with MIT License
from BEagle1984

private static void Main()
        {
            var replacedembly = replacedembly.Getreplacedembly(typeof(ClientConfig));

            if (replacedembly == null)
                throw new InvalidOperationException("Couldn't load ClientConfig replacedembly.");

            var xmlDoreplacedentationPath = Path.Combine(
                Path.GetDirectoryName(replacedembly.Location)!,
                "Confluent.Kafka.xml");

            Console.Write(
                new ProxyClreplacedGenerator(
                        typeof(ClientConfig),
                        "ConfluentClientConfigProxy",
                        null,
                        null,
                        xmlDoreplacedentationPath,
                        false)
                    .Generate());

            Console.WriteLine();

            Console.Write(
                new ProxyClreplacedGenerator(
                        typeof(ConsumerConfig),
                        "ConfluentConsumerConfigProxy",
                        "ConfluentClientConfigProxy",
                        "Confluent.Kafka.ConsumerConfig",
                        xmlDoreplacedentationPath,
                        false)
                    .Generate());

            Console.WriteLine();

            Console.Write(
                new ProxyClreplacedGenerator(
                        typeof(ProducerConfig),
                        "ConfluentProducerConfigProxy",
                        "ConfluentClientConfigProxy",
                        "Confluent.Kafka.ProducerConfig",
                        xmlDoreplacedentationPath,
                        false)
                    .Generate());
        }

19 Source : Program.cs
with Apache License 2.0
from benaadams

[GlobalSetup]
        public void GlobalSetup()
        {
            var replacedembly = replacedembly.Getreplacedembly(typeof(int));
            _types = replacedembly.GetTypes();

            _typeDictionary = new TypeDictionary<int>();
            _dictionary = new Dictionary<Type, int>();

            //_typeDictArray = new TypeDictArray<int>();
            //_typeDictPure = new TypeDictPure<int>();

            for (var i = 0; i < Items; i++)
            {
                _typeDictionary[_types[i]] = i;
                _dictionary[_types[i]] = i;

                //_typeDictArray[_types[i]] = i;
                //_typeDictPure[_types[i]] = i;
            }
        }

19 Source : TypeExtensions.cs
with MIT License
from BenMorris

public static TypeDefinition ToTypeDefinition(this Type type)
        {
            // Get the replacedembly using reflection
            var replacedembly = replacedembly.Getreplacedembly(type);

            // Load the replacedembly into the Mono.Cecil library
            var replacedemblyDef = replacedemblyDefinition.Readreplacedembly(replacedembly.Location);

            // Find the matching type
            var dependencies = (replacedemblyDef.Modules
                .SelectMany(t => t.Types)
                .Where(t => t.IsClreplaced && t.Namespace != null && t.FullName.Equals(type.FullName, StringComparison.InvariantCultureIgnoreCase)));

            return dependencies.FirstOrDefault();
        }

19 Source : SearchTypeTests.cs
with MIT License
from BenMorris

[Theory(DisplayName = "A search for types with ANY dependencies returns types that have a dependency on at least one item in the list.")]
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies.Examples.ExampleDependency", "NetArchTest.TestStructure.Dependencies.Examples.AnotherExampleDependency" }, "List contains two distinct dependencies.")]
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies.Examples.ExampleDependency", "NetArchTest.TestStructure.Dependencies.Examples.AnotherExampleDependency", "NetArchTest.TestStructure.Dependencies" }, "List contains overlapping dependencies.")]
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies" }, "List contains only ancestor namespace.")]
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies", "NetArchTest.TestStructure.Dependencies" }, "List contains duplicated ancestor namespace.")]
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies", "NetArchTest.TestStructure.Dependencies.Examples" }, "List contains overlapping namespaces.")]
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
        public void FindTypesWithAnyDependencies_Found(string[] dependecies, string comment)
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
        {
            // Arrange
            var search = new DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(HasDependency)))
                .That()
                .ResideInNamespace(typeof(HasDependency).Namespace)
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatHaveDependencyOnAny(typeList, dependecies);

            // replacedert
            replacedert.Equal(3, result.Count); // Three types found   
            replacedert.Equal(typeof(HasAnotherDependency).FullName, result.First().FullName); // Correct types returned...
            replacedert.Equal(typeof(HasDependencies).FullName, result.Skip(1).First().FullName);
            replacedert.Equal(typeof(HasDependency).FullName, result.Last().FullName);
        }

19 Source : SearchTypeTests.cs
with MIT License
from BenMorris

[Theory(DisplayName = "A search for types with ALL dependencies returns types that have a dependency on all the items in the list.")]
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies.Examples.ExampleDependency", "NetArchTest.TestStructure.Dependencies.Examples.AnotherExampleDependency" }, "List contains two distinct dependencies.")]
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies.Examples.ExampleDependency", "NetArchTest.TestStructure.Dependencies.Examples.AnotherExampleDependency", "NetArchTest.TestStructure.Dependencies" }, "List contains overlapping dependencies.")]      
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies.Examples.ExampleDependency", "NetArchTest.TestStructure.Dependencies.Examples.AnotherExampleDependency", "NetArchTest.TestStructure.Dependencies.Examples.AnotherExampleDependency" }, "List contains duplicated dependencies.")]
        [InlineData(new string[] { "NetArchTest.TestStructure.Dependencies.Examples.ExampleDependency", "NetArchTest.TestStructure.Dependencies.Examples.AnotherExampleDependency", "NetArchTest.TestStructure.Dependencies", "NetArchTest.TestStructure.Dependencies.Examples" }, "List contains overlapping namespaces.")]
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
        public void FindTypesWithAllDependencies_Found(string[] dependecies, string comment)
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
        {
            // Arrange
            var search = new DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(HasDependency)))
                .That()
                .ResideInNamespace(typeof(HasDependency).Namespace)
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatHaveDependencyOnAll(typeList, dependecies);

            // replacedert
            replacedert.Single(result); // One type found
            replacedert.Equal(typeof(HasDependencies).FullName, result.First().FullName); // Correct type returned
        }

19 Source : SearchTypeTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "A search for types with ANY dependencies returns types that have a dependency on at least one item in the list.")]
        public void FindTypesThatHaveDependencyOnAny_Found()
        {
            // Arrange
            var search = new DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(Clreplaced_A)))
                .That()
                .ResideInNamespace(typeof(Clreplaced_A).Namespace)
                .And()
                .HaveNameStartingWith("Clreplaced")
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatHaveDependencyOnAny(typeList, new string[] { typeof(Dependency_1).FullName, typeof(Dependency_2).FullName });

            // replacedert           
            replacedert.Equal(6, result.Count); 
            replacedert.Equal(typeof(Clreplaced_C).FullName, result[0].FullName);
            replacedert.Equal(typeof(Clreplaced_D).FullName, result[1].FullName);
            replacedert.Equal(typeof(Clreplaced_E).FullName, result[2].FullName);
            replacedert.Equal(typeof(Clreplaced_F).FullName, result[3].FullName);
            replacedert.Equal(typeof(Clreplaced_G).FullName, result[4].FullName);
            replacedert.Equal(typeof(Clreplaced_H).FullName, result[5].FullName);
        }

19 Source : SearchTypeTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "A search for types with ALL dependencies returns types that have a dependency on all the items in the list.")]
        public void FindTypesThatHaveDependencyOnAll_Found()
        {
            // Arrange
            var search = new DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(Clreplaced_A)))
                .That()
                .ResideInNamespace(typeof(Clreplaced_A).Namespace)
                .And()
                .HaveNameStartingWith("Clreplaced")
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatHaveDependencyOnAll(typeList, new string[] { typeof(Dependency_1).FullName, typeof(Dependency_2).FullName });

            // replacedert           
            replacedert.Equal(2, result.Count); 
            replacedert.Equal(typeof(Clreplaced_G).FullName, result[0].FullName);
            replacedert.Equal(typeof(Clreplaced_H).FullName, result[1].FullName);           
        }

19 Source : SearchTypeTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "A search for types with ANY or NONE dependencies returns types that may have a dependency on an item in the list, but cannot have a dependency that is not in the list.")]
        public void FindTypesThatOnlyHaveDependenciesOnAnyOrNone_Found()
        {
            // Arrange
            var search = new DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(Clreplaced_A)))
                .That()
                .ResideInNamespace(typeof(Clreplaced_A).Namespace)
                .And()
                .HaveNameStartingWith("Clreplaced")
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatOnlyHaveDependenciesOnAnyOrNone(typeList, new string[] { typeof(Dependency_1).FullName, typeof(Dependency_2).FullName, "System" });

            // replacedert           
            replacedert.Equal(4, result.Count); 
            replacedert.Equal(typeof(Clreplaced_A).FullName, result[0].FullName);
            replacedert.Equal(typeof(Clreplaced_C).FullName, result[1].FullName);
            replacedert.Equal(typeof(Clreplaced_E).FullName, result[2].FullName);
            replacedert.Equal(typeof(Clreplaced_G).FullName, result[3].FullName);
        }

19 Source : SearchTypeTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "A search for types with ANY dependencies returns types that have a dependency on at least one item in the list, but cannot have a dependency that is not in the list.")]
        public void FindTypesThatOnlyHaveDependenciesOnAny_Found()
        {
            // Arrange
            var search = new DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(Clreplaced_A)))
                .That()
                .ResideInNamespace(typeof(Clreplaced_A).Namespace)
                .And()
                .HaveNameStartingWith("Clreplaced")
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatOnlyHaveDependenciesOnAny(typeList, new string[] { typeof(Dependency_1).FullName, typeof(Dependency_2).FullName, "System" });

            // replacedert           
            replacedert.Equal(4, result.Count); 
            replacedert.Equal(typeof(Clreplaced_A).FullName, result[0].FullName);
            replacedert.Equal(typeof(Clreplaced_C).FullName, result[1].FullName);
            replacedert.Equal(typeof(Clreplaced_E).FullName, result[2].FullName);
            replacedert.Equal(typeof(Clreplaced_G).FullName, result[3].FullName);
        }

19 Source : SearchTypeTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "A search for types with ALL dependencies returns types that have a dependency on all the items in the list, but cannot have a dependency that is not in the list.")]
        public void FindTypesThatOnlyOnlyHaveDependenciesOnAll_Found()
        {
            // Arrange
            var search = new DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(Clreplaced_A)))
                .That()
                .ResideInNamespace(typeof(Clreplaced_A).Namespace)
                .And()
                .HaveNameStartingWith("Clreplaced")
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatOnlyOnlyHaveDependenciesOnAll(typeList, new string[] { typeof(Dependency_1).FullName, typeof(Dependency_2).FullName, "System" });

            // replacedert           
            replacedert.Equal(1, result.Count);
            replacedert.Equal(typeof(Clreplaced_G).FullName, result[0].FullName);          
        }

19 Source : VariousTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "A dependency search will not return false positives for pattern matched clreplacedes.")]
        public void FindTypesWithAllDependencies_PatternMatchedClreplacedes_NotReturned()
        {
            // In this example, searching for a dependency on "PatternMatch" should not return "PatternMatchTwo"

            // Arrange
            var search = new global::NetArchTest.Rules.Dependencies.DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(HasDependency)))
                .That()
                .HaveName("ClreplacedMatchingExample")
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatHaveDependencyOnAll(typeList, new List<string> { typeof(PatternMatch).FullName });

            // replacedert: Before PR#36 this would have returned PatternMatchToo in the results
            replacedert.Empty(result); // No results returned
        }

19 Source : VariousTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "A dependency search will not return false positives for pattern matched namespaces.")]
        public void FindTypesWithAllDependencies_PatternMatchedNamespaces_NotReturned()
        {
            // In this example, searching for a dependency on "NamespaceMatch" should not return clreplacedes in "NamespaceMatchToo"

            // Arrange
            var search = new global::NetArchTest.Rules.Dependencies.DependencySearch();
            var typeList = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(HasDependency)))
                .That()
                .HaveName("NamespaceMatchingExample")
                .GetTypeDefinitions();

            // Act
            var result = search.FindTypesThatHaveDependencyOnAll(typeList, new List<string> { typeof(PatternMatch).Namespace });

            // replacedert: Before PR#36 this would have returned clreplacedes in NamespaceMatchToo in the results
            replacedert.Empty(result); // No results returned
        }

19 Source : ConditionListTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "Conditions can be chained together using 'and' logic.")]
        public void And_AppliedToConditions_SelectCorrectTypes()
        {
            var result = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .ResideInNamespace("NetArchTest.TestStructure.NameMatching")
                .Should()
                .HaveNameStartingWith("Clreplaced")
                .And()
                .HaveNameEndingWith("1")
                .And()
                .BeClreplacedes()
                .GetTypes();

            replacedert.Equal(2, result.Count()); // two types found
            replacedert.Contains<Type>(typeof(ClreplacedA1), result);
            replacedert.Contains<Type>(typeof(ClreplacedB1), result);
        }

19 Source : ConditionListTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "An ShouldNot() statement will inverse the subsequent conditions")]
        public void ShouldNot_FollowingConditions_Inversed()
        {
            // First example - single condition
            var predicates = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .ResideInNamespace("NetArchTest.TestStructure.Interfaces")
                .And()
                .HaveNameStartingWith("Implements");

            var result1 = predicates.Should().ImplementInterface(typeof(IExample)).GetResult();
            var result1Not = predicates.ShouldNot().NotImplementInterface(typeof(IExample)).GetResult();

            // Third example - two conditions with an or() statement
            predicates = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .ResideInNamespace(" NetArchTest.TestStructure.NameMatching.Namespace1");

            var result2 = predicates.Should().HaveNameStartingWith("ClreplacedA").Or().HaveNameStartingWith("ClreplacedB").GetResult();
            var result2Not = predicates.ShouldNot().NotHaveNameStartingWith("ClreplacedA").Or().NotHaveNameStartingWith("ClreplacedB").GetResult();

            replacedert.Equal(result1.IsSuccessful, result1Not.IsSuccessful);
            replacedert.Equal(result2.IsSuccessful, result2Not.IsSuccessful);
        }

19 Source : ConditionTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "Types can be selected if they reside in a namespace that contains a name part.")]
        public void ResideInNamespaceContaining_ClreplacedSelected()
        {
            var result = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .HaveNameStartingWith("ClreplacedA")
                .Should()
                .ResideInNamespaceContaining(".NameMatching.")
                .GetResult();

            replacedert.True(result.IsSuccessful);
        }

19 Source : ConditionTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "Types can be selected if they do not reside in a namespace that contains name part.")]
        public void NotResideInNamespaceContaining_ClreplacedSelected()
        {
            var result = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .HaveNameStartingWith("ClreplacedA")
                .Should()
                .NotResideInNamespaceContaining("Namespace3")
                .GetResult();

            replacedert.True(result.IsSuccessful);
        }

19 Source : ConditionTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "Selecting by namespace will return types in nested namespaces.")]
        public void ResideInNamespace_Nested_AllClreplacedReturned()
        {
            var result = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .HaveName("ClreplacedB2")
                .Should()
                .ResideInNamespace("NetArchTest.TestStructure.NameMatching").GetResult();

            replacedert.True(result.IsSuccessful);
        }

19 Source : ConditionTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "Types can be selected if they have a dependency on a specific item.")]
        public void HaveDependency_MatchesFound_ClreplacedSelected()
        {
            var result = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .ResideInNamespace(typeof(HasDependency).Namespace)
                .And()
                .HaveNameStartingWith("HasDepend")
                .Should()
                .HaveDependencyOn(typeof(ExampleDependency).FullName)
                .GetResult();

            replacedert.True(result.IsSuccessful);
        }

19 Source : ConditionTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "Types can be selected if they have a dependency on any item in a list.")]
        public void HaveDependencyOnAny_MatchesFound_ClreplacedSelected()
        {
            var result = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .ResideInNamespace(typeof(HasDependency).Namespace)
                .And()
                .HaveNameStartingWith("Has")
                .Should()
                .HaveDependencyOnAny(new[] { typeof(ExampleDependency).FullName, typeof(AnotherExampleDependency).FullName })
                .GetResult();

            replacedert.True(result.IsSuccessful);
        }

19 Source : ConditionTests.cs
with MIT License
from BenMorris

[Fact(DisplayName = "Types can be selected if they have a dependency on all the items in a list.")]
        public void HaveDependencyOnAll_MatchesFound_ClreplacedSelected()
        {
            var result = Types
                .Inreplacedembly(replacedembly.Getreplacedembly(typeof(ClreplacedA1)))
                .That()
                .ResideInNamespace(typeof(HasDependency).Namespace)
                .And()
                .HaveNameStartingWith("HasDependencies")
                .Should()
                .HaveDependencyOnAll(new[] { typeof(ExampleDependency).FullName, typeof(AnotherExampleDependency).FullName })
                .GetResult();

            replacedert.True(result.IsSuccessful);
        }

See More Examples