Exemple #1
0
        public SourceAssemblySymbol(
            PhpCompilation compilation,
            string assemblySimpleName,
            string moduleName)
        {
            Debug.Assert(compilation != null);
            Debug.Assert(!String.IsNullOrWhiteSpace(assemblySimpleName));
            Debug.Assert(!String.IsNullOrWhiteSpace(moduleName));

            _compilation = compilation;
            _simpleName  = assemblySimpleName;

            var moduleBuilder = new ArrayBuilder <ModuleSymbol>(1);

            moduleBuilder.Add(new SourceModuleSymbol(this, compilation.SourceSymbolCollection, moduleName));

            //var importOptions = (compilation.Options.MetadataImportOptions == MetadataImportOptions.All) ?
            //    MetadataImportOptions.All : MetadataImportOptions.Internal;

            //foreach (PEModule netModule in netModules)
            //{
            //    moduleBuilder.Add(new PEModuleSymbol(this, netModule, importOptions, moduleBuilder.Count));
            //    // SetReferences will be called later by the ReferenceManager (in CreateSourceAssemblyFullBind for
            //    // a fresh manager, in CreateSourceAssemblyReuseData for a reused one).
            //}

            _modules = moduleBuilder.ToImmutableAndFree();

            if (!compilation.Options.CryptoPublicKey.IsEmpty)
            {
                // Private key is not necessary for assembly identity, only when emitting.  For this reason, the private key can remain null.
                _lazyStrongNameKeys = StrongNameKeys.Create(compilation.Options.CryptoPublicKey, null, Errors.MessageProvider.Instance);
            }
        }
Exemple #2
0
        private StrongNameKeys ComputeStrongNameKeys()
        {
            //// TODO:
            //// In order to allow users to escape problems that we create with our provisional granting of IVT access,
            //// consider not binding the attributes if the command line options were specified, then later bind them
            //// and report warnings if both were used.
            //EnsureAttributesAreBound();

            // when both attributes and command-line options specified, cmd line wins.
            string keyFile = _compilation.Options.CryptoKeyFile;

            // Public sign requires a keyfile
            if (DeclaringCompilation.Options.PublicSign)
            {
                // TODO(https://github.com/dotnet/roslyn/issues/9150):
                // Provide better error message if keys are provided by
                // the attributes. Right now we'll just fall through to the
                // "no key available" error.

                if (!string.IsNullOrEmpty(keyFile) && !PathUtilities.IsAbsolute(keyFile))
                {
                    // If keyFile has a relative path then there should be a diagnostic
                    // about it
                    Debug.Assert(!DeclaringCompilation.Options.Errors.IsEmpty);
                    return(StrongNameKeys.None);
                }

                // If we're public signing, we don't need a strong name provider
                return(StrongNameKeys.Create(keyFile, Errors.MessageProvider.Instance));
            }

            if (string.IsNullOrEmpty(keyFile))
            {
                //keyFile = this.AssemblyKeyFileAttributeSetting;

                //if ((object)keyFile == (object)WellKnownAttributeData.StringMissingValue)
                //{
                //    keyFile = null;
                //}
            }

            string keyContainer = _compilation.Options.CryptoKeyContainer;

            if (string.IsNullOrEmpty(keyContainer))
            {
                //keyContainer = this.AssemblyKeyContainerAttributeSetting;

                //if ((object)keyContainer == (object)WellKnownAttributeData.StringMissingValue)
                //{
                //    keyContainer = null;
                //}
            }

            bool hasCounterSignature = !string.IsNullOrEmpty(this.SignatureKey);

            return(StrongNameKeys.Create(DeclaringCompilation.Options.StrongNameProvider, keyFile, keyContainer, hasCounterSignature, Errors.MessageProvider.Instance));
        }
Exemple #3
0
 internal override void SignFile(StrongNameKeys keys, string filePath) => SignFileFunc(keys, filePath);
 internal override void SignAssembly(StrongNameKeys keys, Stream inputStream, Stream outputStream) =>
     _underlyingProvider.SignAssembly(keys, inputStream, outputStream);
Exemple #5
0
 internal override void SignAssembly(StrongNameKeys keys, Stream inputStream, Stream outputStream) =>
 _underlyingProvider.SignAssembly(keys, inputStream, outputStream);